WCF 如何在自定义绑定上设置 clientCredentialType
我正在使用优秀的 DuplexHttpBinding。我现在想扩展它,以便可以将传输安全性与消息凭据结合使用。我在此模式下设置了一些正常的 BasicHttpBinding
,如下所示:
<basicHttpBinding>
<binding name="BasicHttpBinding_Custom">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
但是,我无法对我的 DuplexHttpBinding
执行相同的操作,因为它没有安全元素。
我的问题是:如何使用 TransportWithMessageCredential
设置我的 DuplexHttpBinding
?或者。更一般地说,如何在通过继承 System.ServiceModel.Channels.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 BasicHttpBinding
s 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是添加一个
SecurityBindingElement
作为BindingElementCollection
中的第一个元素,因此在绑定的CreateBindingElements
方法中:The solution was to add a
SecurityBindingElement
as the first element in theBindingElementCollection
, so in theCreateBindingElements
method of your binding: