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

时间:2017-11-29 10:03:16

标签: c# wcf

    <?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>

我正在尝试将webHttpBinding设置添加到webconfig,但会收到以下错误:

  

无法添加服务。可能无法访问服务元数据。使   确保您的服务正在运行并公开元数据。

0 个答案:

没有答案