简体   繁体   English

WcfTestClient:添加服务失败。 服务元数据可能无法访问

[英]WcfTestClient: Failed to add a service. Service metadata may not be accessible

at the beginning sorry for my English. 一开始对我的英语感到抱歉。

I know that there are already answers for this question but none of them worked for me. 我知道这个问题已经有了答案,但是没有一个对我有用。 I am trying to connect to my database. 我正在尝试连接到我的数据库。

I am working on: 我正在努力:

  • Microsoft Visual Studio Community 2015 version 14.0.25431.01 Update 3. Microsoft Visual Studio Community 2015版本14.0.25431.01更新3。
  • Microsoft .NET Framework Version 4.6.01586 Microsoft .NET Framework版本4.6.01586

I have already checked Tools->Options->Project and Solutions->Web Projects->Use the 64 bit version of IIS Express for web sites and projects. 我已经检查了“工具”->“选项”->“项目和解决方案”->“ Web项目”->“将IIS Express的64位版本用于网站和项目”。

My code from View Markup (Service1.svc): <%@ ServiceHost Language="C#" Debug="true" Service="WCFconnection.Service1" CodeBehind="Service1.svc.cs" %> 我从视图标记(Service1.svc)中得到的代码: <%@ ServiceHost Language =“ C#” Debug =“ true” Service =“ WCFconnection.Service1” CodeBehind =“ Service1.svc.cs”%>

here is my Web.config 这是我的Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXX" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
  </system.web>
  <system.serviceModel>
    <services>   
      <service name="WCFconnection.Service1"
           behaviorConfiguration="metadataBehavior">
        <endpoint address="" binding="basicHttpBinding" contract="WCFconnection.IService1" />
        <endpoint address="basic" binding="basicHttpBinding" contract="WCFconnection.IService1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="localhost:23233/Service1.svc"
              binding="basicHttpBinding" 
              contract="WCFconnection.IService1"
              />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior  name="metadataBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior  name="DefaultBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    <directoryBrowse enabled="true" />
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <connectionStrings>
    <add name="ZPIEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=XXXXXX-XXXXXX;initial catalog=XXXXXX;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="ConStr" connectionString="Data Source=XXXXXXX-XXXXXXXX\XXXXXXX;Initial Catalog=XXXXXXX;Integrated Security=True"/>
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

When I go to website and put localhost:23233 into address I can see all the files, also my Service1.svc. 当我进入网站并将localhost:23233放入地址时,我可以看到所有文件,还有我的Service1.svc。 But if I try to make WcfTestClient I got error: 但是,如果我尝试使WcfTestClient出现错误:

Failed to add a service. 添加服务失败。 Service metadata may not be accessible. 服务元数据可能无法访问。 Make sure your service is running and exposing metadata. 确保您的服务正在运行并公开元数据。

Error: Cannot obtain Metadata from http://localhost:23233/ If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address... 错误:无法从http:// localhost:23233 /获取元数据。如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用元数据发布...

Please help me. 请帮我。

Based on the error that WcfTestClient is giving you, you are not providing the full endpoint url. 根据WcfTestClient给您的错误,您没有提供完整的端点URL。

You are adding http://localhost:23233/ 您正在添加http://localhost:23233/

You should be adding http://localhost:23233/Service1.svc 您应该添加http://localhost:23233/Service1.svc

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 添加服务失败。 服务元数据可能无法访问 - Failed to add a service. Service metadata may not be accessible WCF:无法添加服务。 服务元数据可能无法访问 - WCF:Failed to add a service. Service metadata may not be accessible 添加服务失败。 服务元数据可能无法访问。 确保您的服务正在运行并公开元数据 - Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata 运行WCF服务获取错误添加服务失败。 服务元数据可能无法访问 - Run WCF service getting error Failed to add a service. Service metadata may not be accessible 获取&#39;无法添加服务。 服务元数据可能无法访问。 测试 WCF 项目时出错 - Getting 'Failed to add a service. Service metadata may not be accessible.' error when testing a WCF project WCF测试客户端:无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据 - WCF Test Client : Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata WCF无法添加服务。 可能无法访问服务元数据。 确保您的服务正在运行并公开元数据 - WCF Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata 添加服务失败。 服务元数据可能无法访问。 确保您的服务正在运行并公开元数据。 WCF错误 - Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata. WCF Error WCF:无法添加服务。 可能无法访问服务元数据。 确保您的服务正在运行并公开元数据 - WCF: Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata 服务元数据可能无法访问 - Service metadata may not be accessible
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM