【问题标题】:Wanted: WCF Custom Binding with binaryMessageEncoding & transport security需要:带有 binaryMessageEncoding 和传输安全的 WCF 自定义绑定
【发布时间】:2010-06-10 03:54:29
【问题描述】:

我是 WCF 绑定的新手,如果有任何帮助来制作自定义绑定,我将不胜感激:

  • 支持二进制消息编码。
  • 使用传输安全性 (clientCredentialType="None")。

感谢您的帮助。

【问题讨论】:

    标签: wcf


    【解决方案1】:

    您需要在配置的 <system.serviceModel> 部分创建自定义绑定 - 如下所示:

    <bindings>
      <customBinding>
        <binding name="HttpBinaryBinding">
          <binaryMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    

    您可以在此处定义大量功能和选项 - 元素的顺序很重要 - 传输之前的消息编码,而传输是堆栈中的最后一个选项。请参阅MSDN Docs on Custom Bindings 或 Kirk Evans 的blog post,了解有关所有可用选项的更多详细信息以及如何组合它们的规则。

    定义自定义绑定后,您可以通过在端点上指定 binding="customBinding"bindingConfiguration="HttpBinaryBinding" 来使用它 - 无论是在服务器端还是在客户端。

        <endpoint
          address="http://localhost:8001/myService/"
          binding="customBinding"
          bindingConfiguration="HttpBinaryBinding"
          contract="IMyService"
          name="customHttpBindingEndpoint" />
    

    真的就是这样!

    【讨论】:

    • 感谢您的回复。我查看了提供的链接,但找不到任何将传输安全性添加到绑定的示例。
    • @Bram:使用 而不是
    • 谢谢 Marc_s。还有什么问题,如果我使用httpsTransport,发送到WCF服务的数据内容是加密的吗?
    • @Bram:使用 httpsTransport 加密通信链路上的所有内容。但是:传输安全通常只适用于公司防火墙后面的公司环境 - 通过互联网,您无法保证从客户端到服务器的传输安全。
    • 非常感谢您的帮助 marc_s。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-02
    • 2014-01-31
    • 1970-01-01
    • 2010-11-29
    • 1970-01-01
    相关资源
    最近更新 更多