1

我们有一个具有 4 种服务方法的 WCF 服务,并且在过去 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 位置。

感谢,

@尼鲁

4

1 回答 1

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/

于 2015-08-27T20:12:45.750 回答