6

When trying to pass a small FileStream to my WCF service I get "Timeouts are not supported on this stream" error. Can anyone see what I'm doing wrong?

Interface:

[OperationContract]
List<SystemClass> ReadExcelFile(System.IO.FileStream stream);

Web.Config

<bindings>
  <basicHttpBinding>
    <binding name="streaming" maxReceivedMessageSize="2147483647" transferMode="Streamed">
    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service name="MISDashboard.wcfService" behaviorConfiguration="">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="streaming" contract="MISDashboard.wcfService"></endpoint>
  </service>
</services>
...
<httpRuntime maxRequestLength="2147483647"/>
4

2 回答 2

5

不要FileStream用作参数,但是Stream. AFileStream是绑定到本地文件系统的流;一旦您开始传输数据,另一端的流将来自网络,因此不能在那里使用 FileStream。

您可以相信它几乎相同,但StreamWCF 以特殊方式处理它并绕过许多内部任务。

此外,对于发送大数据,请考虑阅读这篇精彩的文章

于 2013-07-03T07:54:01.797 回答
0

I guess the issue over here is about the ReadTimeOut and WriteTimeOut properties. Under the hood WCF must be trying to set them up and as these are not implemented in FileStream class it throws the exception. So if you define the method Argument type as Stream WCF should create the appropriate stream that is required for data streaming. I would guess NetworkStream.

于 2013-07-03T20:45:59.610 回答