2

I am writing a WCF Web Service which support SOAP and REST. I also enabled the WCF REST Help Page which is very useful for the consumers of the Web Service. Since I enabled SSL in IIS and in the web.config (see below), I can't get the WCF REST Help Page anymore. If I access https://myHost/myWebService/help, I get a HTTP 404 error. Prior to enabling SSL, I could access that page.

Below is my web.config. Can someone please help me understand how to enable WCF REST Help Page over HTTPS/SSL?

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

    <services>
      <service name="MyNs.MyServiceWebserviceImpl" behaviorConfiguration="DefaultBehavior">
        <endpoint name="MyServiceRestEndpoint" address="" binding="webHttpBinding" behaviorConfiguration="MyServiceRestBehavior" contract="MyNs.IMyServiceWebservice" />
        <endpoint name="MyServiceSoapEndpoint" address="soap" binding="basicHttpBinding" bindingConfiguration="MyServiceSoapBinding" behaviorConfiguration="MyServiceSoapBehavior" contract="MyNs.IMyServiceWebservice"  />
        <endpoint name="MyServiceMexEndpoint" address="mex" binding="mexHttpsBinding" bindingConfiguration="" contract="IMetadataExchange" />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultBehavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
        <behavior name="MyServiceRestBehavior">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
        </behavior>

        <behavior name="MyServiceSoapBehavior" />
      </endpointBehaviors>
    </behaviors>

    <bindings>
      <webHttpBinding>
        <binding name="MyServiceRestBinding">
          <security mode="Transport" />
        </binding>
      </webHttpBinding>

      <basicHttpBinding>
        <binding name="MyServiceSoapBinding">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>

  </system.serviceModel>

</configuration>
Martin
  • 39,309
  • 62
  • 192
  • 278

1 Answers1

0

The httpGetEnabled and httpsGetEnabled attributes of the serviceMetadata element control the access to the service WSDL document. For a webHttpBinding based endpoint, providing a WSDL document is not applicable since WCF provides an automatically generated Help "web site" to document the service.

Use the webHttp endpoint behavior to enable the Help site for as shown on this MSDN page.

UPDATE: since I overlooked that the config in the question all ready had the suggestion...

It appears that getting multiple bindings and SSL working correct may require more configuration than is obvious. This MSDN forum question and answer provide more detail. It uses a WCF 4.0 configuration feature called standardEndpoint. The answer also contains a ZIP file with sample code.

Sixto Saez
  • 12,610
  • 5
  • 43
  • 51
  • I already have webHttp helpPage attribute enabled. Using HTTPS, the page doesn't render. It results in a 404. – Martin Jan 10 '14 at 14:26
  • Sorry, didn't notice it in the rush to answer :) Sooo, what you have should work. Do you get anything if you try to access the Help with HTTP (with the endpoint still configured for SSL)? – Sixto Saez Jan 10 '14 at 14:31
  • The HTTP version is blocked because IIS is set to require SSL. If I disable that, the page comes back. The issue is that I don't want to disable SSL, I need it. – Martin Jan 10 '14 at 14:34
  • That behavior implies that the WCF Help configuration is correct (duuh). So either IIS is failing to pass the request to the WCF service and returning 404 or WCF is receiving the request but doesn't recognize the request URL as valid so it returns 404. I'd recommend enabling [WCF tracing](http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx) to trace All activity. First, enable tracing and try it with HTTP to ensure WCF will trace the Help page request then enable HTTPS and run the tracing. It's gotta be either an issue in IIS or a "feature" in WCF. – Sixto Saez Jan 10 '14 at 15:28