Close

WCF Service with Http endpoint and Https endpoint

To have a WCF webservice with a http and a https endpoint.
– Install the service under the default website. Don’t install the webservice twice under both the DefaultWebSite and a SecureWebsite.
– Create a self-signed certificate.
– Edit bindings of the Default Website. Add binding for port 80 (http) and port 443 (https).
– Change web.config file in line with the example below:

<system.serviceModel>
<bindings>
<customBinding>
        <binding name=”RawReceive”>
          <webMessageEncoding webContentTypeMapperType=”Rfs.Integration.Common.REST.ContentTypeMapper.XmlContentTypeMapper, Rfs.Integration.Common.REST.ContentTypeMapper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e01eb028bb23e431″ />
          <httpTransport manualAddressing=”true” maxReceivedMessageSize=”524288000″ transferMode=”Streamed” />
        </binding>
        <binding name=”RawReceiveSecure”>
          <webMessageEncoding webContentTypeMapperType=”Rfs.Integration.Common.REST.ContentTypeMapper.XmlContentTypeMapper, Rfs.Integration.Common.REST.ContentTypeMapper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e01eb028bb23e431″ />
          <httpsTransport manualAddressing=”true” maxReceivedMessageSize=”524288000″ transferMode=”Streamed” />
        </binding>
</customBinding>
</bindings>
<services>
<service behaviorConfiguration=”RESTServiceBehavior” name=”Rfs.Integration.Common.REST.MessageService.MessageService”>
        <endpoint address=”” behaviorConfiguration=”RESTEndpointBehavior”
          binding=”customBinding” bindingConfiguration=”RawReceive” contract=”Rfs.Integration.Common.REST.MessageService.IMessageService” />
        <endpoint address=”” behaviorConfiguration=”RESTEndpointBehavior”
          binding=”customBinding” bindingConfiguration=”RawReceiveSecure” contract=”Rfs.Integration.Common.REST.MessageService.IMessageService” />
      </service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name=”RESTServiceBehavior” >
<serviceMetadata httpGetEnabled=”true” httpsGetEnabled=”true”/>
<serviceDebug includeExceptionDetailInFaults=”false”/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name=”RESTEndpointBehavior”>
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” multipleSiteBindingsEnabled=”true” />
</system.serviceModel>