title: Publish WCF Service in IIS with support for both HTTP and HTTPS
body: <p>I have a WCF-Service configured with two endpoints using webHttpBinding, one for http and the other for https. They use the same address, the endpoints just differ by the used protocol:</p>
  
  <p><code>&lt;services&gt;<br>
      &lt;service name="Blubb.ClientService"&gt;<br>
          &lt;endpoint binding="webHttpBinding" bindingConfiguration="webBindingConfig" behaviorConfiguration="webBehaviour" 
  contract="Blubb.Contracts.IClientService"/&gt;<br>
          &lt;endpoint binding="webHttpBinding" bindingConfiguration="sslWebBindingConfig" behaviorConfiguration="webBehaviour" 
  contract="Blubb.Contracts.IClientService"/&gt;
        &lt;/service&gt;<br>
  &lt;services&gt;
  </code></p>
  
  <p>using the following behaviours and bindings:</p>
  
  <p><code>
  &lt;behaviors&gt;<br>
    &lt;endpointBehaviors&gt;<br>
      &lt;behavior name="webBehaviour"&gt;<br>
        &lt;webHttp/&gt;<br>
      &lt;/behavior&gt;<br>
    &lt;/endpointBehaviors&gt;<br>
  &lt;/behaviors&gt;<br>
      &lt;bindings&gt;<br>
        &lt;webHttpBinding&gt;<br>
          &lt;binding name="webBindingConfig"&gt;<br>
            &lt;security mode="None"/&gt;<br>
          &lt;/binding&gt;<br>
          &lt;binding name="sslWebBindingConfig"&gt;<br>
            &lt;security mode="Transport"/&gt;<br>
          &lt;/binding&gt;<br>
        &lt;/webHttpBinding&gt;<br>
      &lt;/bindings&gt;
  </code></p>
  
  <p>Both endpoints work fine when I have the certificate installed on IIS 6.</p>
  
  <p>When the certificate is not installed, the HTTPS-Endpoint certainly won't work. But the HTTP-Endpoint doesn't work either. It fails with an irritating exception: when I access the service with <a href="http://localhost:8080/ClientManagement/ClientService.svc/GetPackageInfo" rel="nofollow">http://localhost:8080/ClientManagement/ClientService.svc/GetPackageInfo</a> the exception is:</p>
  
  <p><code>
  Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http].
  </code></p>
  
  <p>which is irritating because I didn't request an HTTPS-URL.</p>
  
  <p>Now when I split the service into two, the HTTP-Access also works on the IIS on which the SSL-Certificate is not installed:</p>
  
  <p><code>&lt;services&gt;<br>
  &lt;service name="Blubb.ClientService"&gt;
          &lt;endpoint binding="webHttpBinding" bindingConfiguration="webBindingConfig" behaviorConfiguration="webBehaviour" 
  contract="Blubb.Contracts.IClientService"/&gt;<br>
  &lt;/service&gt;<br>
  &lt;service name="Blubb.ClientServiceSecure"&gt;<br>
  &lt;endpoint binding="webHttpBinding" bindingConfiguration="sslWebBindingConfig" behaviorConfiguration="webBehaviour" 
  contract="Blubb.Contracts.IClientService"/&gt;<br>
  &lt;/service&gt;<br>
  &lt;/services&gt;
  </code></p>
  
  <p>The problem now is that the client has to use two different endpoints instead of just changing the protocol. We have a system where the customer can turn on SSL via our Configuration-Tool depending on their security needs. But I don't want to force them to change the web.config of the WCF-Service.</p>