WCF Service configuration HTTPS with CustomBinding

RBrowning99 picture RBrowning99 · Oct 7, 2013 · Viewed 18.1k times · Source

I needed a custombinding on a WCF Service to allow me to pass raw content to WCFRest service. Works great, but I can't get it to accept transport level security. I want https and basicauthentication as I use elsewhere. Endpoint looks like this:

   <endpoint address="" behaviorConfiguration="web" contract="SmsService.ISmsReceive" binding="customBinding" bindingConfiguration="RawReceiveCapable"></endpoint>

customBinding looks like this:

  <customBinding>
    <binding name="RawReceiveCapable">
      <security mode="Transport">
        <transport clientCredentialType="Basic"/>
      </security>
      <webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
    </binding>
  </customBinding>

but system complains that mode attribute is not allowed in the security node. Without the security node all works great but it's not https.

Thanks

Ray

Answer

Seymour picture Seymour · Oct 7, 2013

I think you need to drop the <security> element and then change the httpTransport element to httpsTransport as shown in the following example:

<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="RawReceiveCapable">
              <webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
              <httpsTransport authenticationScheme="Basic"  manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
            </binding>
        </customBinding>
    </bindings>

The following link might be helpful: http://msdn.microsoft.com/en-us/library/ms731818.aspx