WCF Metadata publishing for this service is curren

2019-09-15 10:40发布

问题:

I am struggling to display metadata while using WCF.

I have looked all over the place. I'm not sure if it is a setting in my web.config file, or my actual service is not working properly. But I get the "Metadata publishing for this service is currently disabled." page when I debug.

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="myWebHttp"/>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="EDSCoastmap">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp/>
        </behavior>
        <behavior name="jsonWebHttp">
          <enableWebScript/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="EDSCoastmap" name="EDS_CoastmapRest.EDSCoastmap">
        <endpoint behaviorConfiguration="webHttp" binding="webHttpBinding"
          bindingConfiguration="myWebHttp" contract="EDS_CoastmapRest.IEDSCoastmap" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
</configuration>

回答1:

Your service doesn't have SOAP endpoint so there are no valid metadata to be exposed. You don't need neither serviceMetadata behavior or MEX endpoint if you don't have SOAP service.

Btw. how do you debug the service?