Search code examples
vb.netrestwcf

RESTful WCF Service errors when hosted on HTTPS only


A few years ago I followed this RESTful WCF Services with No svc file and No config very useful article on setting up RESTful WCF with out using svc files and worked like a dream. But recently I've had to move the site over to HTTPS (still keeping the HTTP for testing) and all worked fine, until I removed the binding for the HTTP site and I get an error message that points back to this entry in the web.config:

<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>

Removing the entry fixes the error, but it stops the auto generated help page that this setting provides.

Here is a brief snippet of the 2 errors that is thrown:

Exception: System.ServiceModel.ServiceActivationException: The service '/myService' cannot be activated due to an exception during compilation. The exception message is: Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].. ---> System.InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [https].

Exception: System.ServiceModel.ServiceActivationException: The service '/MyService' cannot be activated due to an exception during compilation. The exception message is: An endpoint reference cycle was detected in your configuration. The following reference cycle must be removed: webHttpEndpoint/, webHttpEndpoint/. (...\web.config line 222). ---> System.Configuration.ConfigurationErrorsException: An endpoint reference cycle was detected in your configuration. The following reference cycle must be removed: webHttpEndpoint/, webHttpEndpoint/. (...\web.config line 222)

Hoping someone has seen and fixed this problem before.


Solution

  • Figured this, so I needed a binding, the updated web.config is like this:

    <bindings>
      <webHttpBinding>
        <binding>
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    
    
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />                 
      </webHttpEndpoint>
    </standardEndpoints>