我们有一个WCF服务,有4种服务方式&运行良好的过去4年。现在客户端需要一种新的服务方法,可能会返回10K到100万条记录。我们已经使用单独的服务进行了测试,发现响应xml的大小约为36MB到200 MB,处理时间大约需要4秒到7-8秒。我们在客户端webconfig文件中进行了以下更改 -
<bindings>
<basicHttpBinding>
<binding name="wsHttpBinding"
maxReceivedMessageSize="2147483647"
</binding>
</basicHttpBinding>
</bindings>
我们担心,如果我们在现有服务中添加此服务方法并将maxReceivedMessageSize更改为max,则可能会影响整个服务的内存消耗。并且在同时进行方法调用的情况下,它可能导致内存异常。
但客户希望在现有服务中使用这种新服务方法。请提出我们可以提供的解决方案。客户不希望将信息作为zip文件发送,因为他们必须设置单独的FTP位置。
感谢,
@Niru
答案 0 :(得分:0)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- Create a custom binding for our service to enable sending large amount of data -->
<binding name="MyBasicHttpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<!-- Enable the serializer to serialize greater number of records -->
<behavior name="SilverlightWCFLargeDataApplication.Web.SilverlightWCFServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"/>
<services>
<!-- Bind the WCF service to our custom binding -->
<service behaviorConfiguration="SilverlightWCFLargeDataApplication.Web.SilverlightWCFServiceBehavior"
name="SilverlightWCFLargeDataApplication.Web.SilverlightWCFService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract="SilverlightWCFLargeDataApplication.Web.SilverlightWCFService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
阅读这篇文章,也许是你的回答。 https://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/