title: Deploying WCF Service with both http and https bindings/endpoints
body: <p>I've written a WCF web service for consumption by a Silverlight app.  Initially, the service only required a basic http binding.  We now need to be able to deploy the service for use under both http and https.  I've found some settings for web.config that allow me to do this as follows:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;behaviors&gt;
      &lt;endpointBehaviors&gt;
        &lt;behavior name="SilverlightFaultBehavior"&gt;
          &lt;silverlightFaults /&gt;
        &lt;/behavior&gt;
      &lt;/endpointBehaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name="CxtMappingWebService.CxtMappingWebServiceBehavior"&gt;
          &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="True" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
    &lt;bindings&gt;
      &lt;basicHttpBinding&gt;
        &lt;binding name="SecureHttpBinding"&gt;
          &lt;security mode="Transport" /&gt;
        &lt;/binding&gt;
        &lt;binding name="BasicHttpBinding"&gt;
          &lt;security mode="None" /&gt;
        &lt;/binding&gt;
      &lt;/basicHttpBinding&gt;
    &lt;/bindings&gt;
    &lt;services&gt;
      &lt;service name="CxtMappingWebService.CxtMappingWebService" behaviorConfiguration="CxtMappingWebService.CxtMappingWebServiceBehavior"&gt;
        &lt;endpoint address="" bindingConfiguration="SecureHttpBinding" binding="basicHttpBinding" contract="CxtMappingWebService.ICxtMappingWebService" behaviorConfiguration="SilverlightFaultBehavior" /&gt;
        &lt;endpoint address="" bindingConfiguration="BasicHttpBinding" binding="basicHttpBinding" contract="CxtMappingWebService.ICxtMappingWebService" behaviorConfiguration="SilverlightFaultBehavior" /&gt;
        &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Unfortunately, however, there's a problem with this.  </p>
  
  <p>This web service needs to be deployed to hundreds of our customers' servers, and not all of them will be using https.  Deploying it to a server that doesn't have an https binding set up in IIS causes it to fail.  Is there a way to have both of these bindings in the web.config by default without it dying if there's not an https binding set up in IIS?  </p>
  
  <p>We've got a possible solution for this problem, but it doesn't really fit well with our deployment requirements.  </p>
  
  <p>Has anybody else encountered anything like this before, and how did you resolve it?</p>