【发布时间】:2018-02-19 15:19:48
【问题描述】:
我想开始我应该问流式 WCF 是否可以在没有 MTOM 的情况下工作,或者是否需要 MTOM?我使用的是 MTOM,但它不适用于我们基于 Mono 的 macOS 客户端,因此我们不得不将其关闭。
我们有一个托管在 IIS 上的 WCF Web 应用程序。
这是客户端上的绑定:
<binding name="BasicHttpBinding_IDataService" transferMode="Streamed"
sendTimeout="01:05:00" maxReceivedMessageSize="504857600">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
</security>
</binding>
这是服务器上的绑定:
<binding name="BasicHttpBinding_IDataService" transferMode="Streamed" sendTimeout="01:05:00" maxReceivedMessageSize="130000000">
<readerQuotas maxArrayLength="104857600" maxStringContentLength="104857600" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
</security>
</binding>
我调用了客户端上名为 ReceiveAsync 的方法之一。它返回一个流对象。然后我调用流对象来下载数据。
我遇到的问题是,在整个文件返回之前,对 ReceiveAsync 的调用似乎不会返回,这看起来更像是缓冲而不是流。
如果它在足够慢的网络连接上运行,它会在调用 ReceiveAsync 时超时。
为什么 ReceiveAsync 不立即返回,然后允许我流式传输文件数据?
【问题讨论】:
-
据我所知,我不需要 MTOM。这只是二进制数据的编码。我还进行了额外的调试,看起来即使绑定确实显示了流式传输,但消息没有流式传输。在下载整个文件数据之前,WCF 方法调用不会返回。那为什么会这样呢?