【问题标题】:WCF How can I set clientCredentialType on custom bindingWCF 如何在自定义绑定上设置 clientCredentialType
【发布时间】:2010-07-13 09:28:59
【问题描述】:

我正在使用出色的DuplexHttpBinding。我现在想扩展它,以便我可以使用带有消息凭据的传输安全性。我在这种模式下设置了一些普通的BasicHttpBindings,如下所示:

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

但是我不能对我的DuplexHttpBinding 做同样的事情,因为它没有安全元素。

我的问题是:如何使用TransportWithMessageCredential 设置我的DuplexHttpBinding?或者。更一般地说,如何在通过继承 System.ServiceModel.Channels.Binding 创建的绑定上设置消息安全性?

我一直在努力寻找有关此的任何信息,因此非常欢迎任何指向相关文档的链接!

【问题讨论】:

    标签: .net wcf wcf-security


    【解决方案1】:

    解决方案是在BindingElementCollection 中添加SecurityBindingElement 作为第一个元素,因此在绑定的CreateBindingElements 方法中:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-05
      • 1970-01-01
      • 1970-01-01
      • 2010-10-08
      • 1970-01-01
      • 2017-04-19
      • 2011-09-05
      • 1970-01-01
      相关资源
      最近更新 更多