views:

43

answers:

1

I'm using the excellent DuplexHttpBinding. I now want to extend it so that I can use transport security with message credentials. I have some normal BasicHttpBindings set up in this mode like so:

<basicHttpBinding>
    <binding name="BasicHttpBinding_Custom">
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName"/>
      </security>
    </binding>
</basicHttpBinding>

However I can't do the same thing with my DuplexHttpBinding because it doesn't have security element.

My question is: how can I set up my DuplexHttpBinding with TransportWithMessageCredential? Or. more generally, how do you set up the message security on a binding you've created by inheriting from System.ServiceModel.Channels.Binding?

I've been struggling to find any info about this, so any links to relevant docs would be very welcome!

A: 

The solution was to add a SecurityBindingElement as the first element in the BindingElementCollection, so in the CreateBindingElements method of your binding:

SecurityBindingElement security = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
collection.Add(security);
Geoff
Great- so accept your own answer then!
nitzmahone