2010-07-13 63 views
1

我使用优秀的DuplexHttpBinding。我现在想扩展它,以便使用传输安全性和消息凭证。我有一些正常BasicHttpBinding S IN此模式下设置像这样:WCF如何在自定义绑定上设置clientCredentialType

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

但是我不能做同样的事情与我DuplexHttpBinding,因为它不具备安全元素。

我的问题是:如何设置我的DuplexHttpBindingTransportWithMessageCredential?要么。更一般地说,您如何在从System.ServiceModel.Channels.Binding继承而来的绑定中设置邮件安全性?

我一直在努力寻找关于此的任何信息,所以任何有关文档的链接将非常欢迎!

回答

1

的解决方案是一个SecurityBindingElement添加作为第一要素的BindingElementCollection,所以在你的绑定的CreateBindingElements方法:

SecurityBindingElement security = SecurityBindingElement.CreateUserNameOverTransportBindingElement(); 
collection.Add(security); 
+0

Great-所以接受你自己的答案呢! – nitzmahone 2010-07-16 03:57:50

相关问题