niru
niru

Reputation: 11

WCF - How to handing service method returning 1 million data

We have a WCF service with 4 service method & running well for last 4 years. Now client has requirement for a new service method which may return 10K to 1 million record. We have tested it with separate service and found that size of response xml is about 36MB to 200 MB and processing time it takes about 4 sec to 7-8 sec. We have made following changed in client webconfig file-

<bindings>
    <basicHttpBinding>
        <binding name="wsHttpBinding" 
                 maxReceivedMessageSize="2147483647" 
        </binding>
    </basicHttpBinding>
</bindings>

We have a fear that if we add this service method in existing service and changed maxReceivedMessageSize to max it may impact the memory consumption for whole service. And in case of simultaneous method call it may result out of memory kind of exception.

But client want to have this new service method in existing service. Please suggest what possible solution we can have. Client dont want to steam the information and sending as a zip file as for that they have to set up separate FTP location.

Thank,

@Niru

Upvotes: 1

Views: 532

Answers (1)

rojikku4
rojikku4

Reputation: 1

<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>

Read this article, maybe your answer. https://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/

Upvotes: 0

Related Questions