使用 WCF 上传 50MG 文件的最佳方式是什么?
我以为 MTOM 会自动处理这个问题。
我想我错了...
即使在 LocalHost 上运行也会发生异常
(我假设使用外部 IIS 会更糟糕)。
异常消息:
“接收对http://localhost:7064/DataSyncService.svc的 HTTP 响应时发生错误 。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于 HTTP 请求上下文被中止服务器(可能是由于服务关闭)。有关更多详细信息,请参阅服务器日志。”
服务器配置:
<system.serviceModel>
<client>
<remove contract="IMetadataExchange" name="sb" />
</client>
<bindings>
<wsHttpBinding>
<binding name="DataSyncBinding" messageEncoding="Mtom" maxReceivedMessageSize ="50000000" maxBufferPoolSize="50000000">
<readerQuotas maxArrayLength="50000000" />
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Server.DataSyncServiceBehavior" name="Server.DataSyncService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="DataSyncBinding" name="DataSyncService"
contract="Server.IDataSyncService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Server.DataSyncServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>
客户端配置:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="DataSyncService" closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:30:00" sendTimeout="00:30:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:7064/DataSyncService.svc"
binding="wsHttpBinding" bindingConfiguration="DataSyncService"
contract="DataSyncServiceReference.IDataSyncService" name="DataSyncService" />
</client>
</system.serviceModel>
提前致谢。