开发者

WCF How can I set clientCredentialType on custom binding

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 Transpor开发者_如何学GotWithMessageCredential? 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!


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜