Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service configuration HTTPS with CustomBinding

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

like image 365
RBrowning99 Avatar asked Oct 07 '13 18:10

RBrowning99


People also ask

What is custom binding in WCF?

In this article Custom bindings can be built from a set of system-provided binding elements or can include user-defined custom binding elements. You can use custom binding elements, for example, to enable the use of new transports or encoders at a service endpoint.

Which of the following are valid transport binding elements when defining a custom binding?

You must add the binding elements in the following order: Transaction Flow, Reliable Session, Security, Composite Duplex, One-way, Stream Security, Message Encoding, and Transport. Note that not all the binding elements listed are required in every binding.


1 Answers

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

like image 148
Seymour Avatar answered Nov 12 '22 15:11

Seymour