tags:

views:

34

answers:

1

I'm a newb to WCF bindings and would appreciate any help making a custom binding that:

  • Supports Binary Message encoding.
  • Uses Transport Security (clientCredentialType="None").

Thanks for any help.

A: 

You need to create a custom binding in your <system.serviceModel> section of the config - something like this:

<bindings>
  <customBinding>
    <binding name="HttpBinaryBinding">
      <binaryMessageEncoding />
      <httpTransport />
    </binding>
  </customBinding>
</bindings>

There's a ton of features and options you can define here - the sequence of the elements is important - message encoding before transport, and transport is the last of the options in the stack. See the MSDN Docs on Custom Bindings or Kirk Evans' blog post for more details on all available options and rules how to combine them.

Once you've defined your custom binding, you can use it by specifying binding="customBinding" and then bindingConfiguration="HttpBinaryBinding" on your endpoints - both on the server side as well as on the client side.

    <endpoint
      address="http://localhost:8001/myService/"
      binding="customBinding"
      bindingConfiguration="HttpBinaryBinding"
      contract="IMyService"
      name="customHttpBindingEndpoint" />

That's really all there is!

marc_s
Thanks for the reply. I looked at the links provided but I can't find any example to add Transport security to the binding.
Bram
@Bram: use the <httpsTransport /> instead of <httpTransport />
marc_s
Thanks Marc_s. How more question, if I use httpsTransport, the contents of the data being sent to the WCF service is encrypted right?
Bram
@Bram: using httpsTransport encrypts everything on the communications link. However: transport security typically only works in company environments behind corporate firewalls - over the internet, you cannot guarantee transport security all the way from the client to your server.
marc_s
Thanks a lot for your help marc_s.
Bram