【问题标题】:Can I convert this wsHttpBinding to a custom WCF binding that supports streaming?我可以将此 wsHttpBinding 转换为支持流的自定义 WCF 绑定吗?
【发布时间】:2021-01-28 07:17:53
【问题描述】:

我对 WCF 不是很熟悉,但我最近继承了一个旧 API,它使用以下 wsHttpBinding 的两个版本,并且我的任务是向它添加一个使用流式传输的新 API 调用。

<wsHttpBinding>
  <binding name="wsHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="0" receiveTimeout="05:00:00" sendTimeout="05:00:00">
    <readerQuotas maxArrayLength="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" maxDepth="64" maxBytesPerRead="66560" />
    <security mode="None/Transport">
      <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
    </security>
  </binding>
</wsHttpBinding>

注意:QA 版本使用安全模式None,prod 版本使用安全模式Transport,除此之外它们是相同的。

虽然这种类型的绑定不支持流式传输,但似乎当前未使用可靠会话(假设缺少 &lt;reliableSession&gt; 元素意味着它已被禁用),所以我想知道是否有可能将其转换为 customBinding,其工作方式相同,但为将使用它的调用启用了流式传输。

我很久以前就看到BindingBox 回答了类似的问题,这是一个看似非常有用的工具,但已不再可用。很遗憾一直找不到镜像或者源代码,所以没有这个工具,我怎么判断这个自定义绑定是否可行,如果可以,是否创建呢?

【问题讨论】:

  • 客户端和服务器必须在 WCF 中使用相同的绑定。如果要使用自定义绑定,客户端和服务器必须使用相同的自定义绑定。

标签: wcf wcf-binding


【解决方案1】:

经过大量搜索,我根据this very old blog postthe customBinding documentation拼凑了以下内容。这相当于None 安全模式;对于Transport 安全模式,只需将httpTransport 元素名称替换为httpsTransport

<customBinding>
  <binding name="wsHttpStreamBinding" receiveTimeout="05:00:00" sendTimeout="05:00:00">
    <textMessageEncoding>
      <readerQuotas maxArrayLength="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" maxDepth="64" maxBytesPerRead="66560" />
    </textMessageEncoding>
    <httpTransport transferMode="Streamed" maxReceivedMessageSize="2147483647" maxBufferSize="104857600" />
  </binding>
</customBinding>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 2015-06-02
    • 1970-01-01
    • 2012-02-16
    • 2015-03-15
    • 2018-02-13
    • 2018-04-27
    相关资源
    最近更新 更多