简体   繁体   English

添加服务失败无法访问服务元数据。 错误:无法从http:// localhost获取元数据:

[英]Failed to add a service Service metadata may not be accessible . Error: Cannot obtain Metadata from http://localhost:

    <?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfService1.Service1" behaviorConfiguration="web">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="webHttp" bindingConfiguration="" contract="WcfService1.IService1"></endpoint>
       <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
            <behavior name="webHttp">
              <webHttp/>
            </behavior>
          </endpointBehaviors>
      <serviceBehaviors>
        <behavior  name="web">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <!--<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>-->
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <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"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

I am trying to add webHttpBinding setting to webconfig but get the following error: 我正在尝试将webHttpBinding设置添加到webconfig,但是出现以下错误:

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

You have this problem because you have commented out serviceMetadata element in web behavior. 您有此问题,因为您已注释掉web行为中的serviceMetadata元素。 Without it service metadata is not actually published. 没有它,服务元数据实际上不会发布。 Just uncomment it back and the problem will be fixed: 只需取消注释即可,问题将得到解决:

<behavior name="web">
  <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
  <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
  <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
  <serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>

暂无
暂无

声明:本站的技术帖子网页,遵循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 WcfTestClient:添加服务失败。 服务元数据可能无法访问 - WcfTestClient: Failed to add a service. Service metadata may not be accessible 运行WCF服务获取错误添加服务失败。 服务元数据可能无法访问 - Run WCF service getting error Failed to add a service. Service metadata may not be accessible 错误:无法从 http://localhost 获取元数据:如果这是 Windows (R) Communication Foundation 服务 - Error: Cannot obtain Metadata from http://localhost: If this is a Windows (R) Communication Foundation service 添加服务失败。 服务元数据可能无法访问。 确保您的服务正在运行并公开元数据。 WCF错误 - Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata. WCF Error 服务元数据可能无法访问 - 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 获取&#39;无法添加服务。 服务元数据可能无法访问。 测试 WCF 项目时出错 - Getting 'Failed to add a service. Service metadata may not be accessible.' error when testing a WCF project 错误:无法从 WCF 服务获取元数据 - Error: Cannot obtain Metadata from WCF service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM