Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

Can I convert this wsHttpBinding to a custom WCF binding that supports streaming?

I'm not very familiar with WCF, but I recently inherited an old API that uses two versions of the following wsHttpBinding, and I've been tasked with adding a new API call to it that uses streaming.

<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>

Note: The version for QA uses security mode None, while the version for prod uses security mode Transport, but otherwise they're the same.

While streaming is not supported for this type of binding, it appears that reliable sessions are not currently being used (assuming the lack of a <reliableSession> element means it's disabled), so I'm wondering if it might be possible to convert this to a customBinding that works identically but with streaming enabled for the one call that will use it.

I've seen similar questions answered long ago with BindingBox, a seemingly very useful tool that is no longer available. I unfortunately haven't been able to find a mirror or the source code, so without this tool, how can I determine if this custom binding is possible, and if so, go about creating it?

question from:https://stackoverflow.com/questions/65932570/can-i-convert-this-wshttpbinding-to-a-custom-wcf-binding-that-supports-streaming

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After a lot of searching, I pieced together the following based on this very old blog post and the customBinding documentation. This is the equivalent of None security mode; for Transport security mode, just replace the httpTransport element name with 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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...