我对 .NET、C# 和 WCF 很陌生,我正在尝试创建一个服务,该服务将公开方法以允许上传和下载大量对象(对象数组)。我看过很多关于 WCF 中大文件传输的帖子,但我似乎找不到任何专注于上传和下载大量可序列化对象的内容。
我已经能够“破解” web.config 文件以获取允许的字节数和超时限制等,但我想知道是否实际上有更好的方法来配置WCF
更好的速度和内存使用以允许此类传输。因为我已经根据我的测试结果配置了 web.settings(如果超时/字节限制超过,用一些疯狂的大数字增加限制等)我怀疑我的配置是否有意义。
其次,我已经看到了一些实现选项,例如具有 binding TransferMode = Streaming or MTOM
,但我不知道它们是否适用于我的场景。有人可以指出我正确的方向吗?
抱歉,我可能没有很好地构建我的问题,但我们将不胜感激。
以下是我的 web.config 设置:
<system.web>
<httpRuntime maxRequestLength="409600000" executionTimeout="360000"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHTTP" closeTimeout="00:01:00" receiveTimeout="01:00:00"
sendTimeout="01:00:00" maxBufferSize="655360000" maxReceivedMessageSize="655360000"
messageEncoding="Text" />
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WebService.WebService">
<endpoint address="" behaviorConfiguration="BasicEndPoint" binding="basicHttpBinding"
bindingConfiguration="BasicHTTP" name="BasicHTTP" contract="WebService.IWebService" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="BasicEndPoint">
<dataContractSerializer maxItemsInObjectGraph="65536000" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="204800000" />
</requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>