Introduction
In this article , i will explain what configuration settings we need to make to enable transferring of large amounts of data with WCF.
Setting The Configurations
The first configuration settings we need to make is in bindings section.We need to set maxBufferSize and maxReceivedMessageSize to '2147483647'.This is the max data we can transfer with WCF.
<bindings>
<basichttpbinding>
<binding allowcookies="false" bypassproxyonlocal="false" closetimeout="00:01:00" hostnamecomparisonmode="StrongWildcard" maxbufferpoolsize="524288" maxbuffersize="2147483647" maxreceivedmessagesize="2147483647" messageencoding="Text" name="BasicHttpBinding_ICom_ComContract" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00" textencoding="utf-8" transfermode="Buffered" usedefaultwebproxy="true">
<readerquotas maxarraylength="16384" maxbytesperread="4096" maxdepth="32" maxnametablecharcount="16384" maxstringcontentlength="8192"></readerquotas>
</binding>
</basichttpbinding>
</bindings>
The second configuration change we need to make is to add two behaviors in configuratio, serviceBehaviors and endpointBehaviors. In both these behaviors we need to set datacontractSerializer maxItemsInObjectGraph value to '2147483647'
<behaviors>
<servicebehaviors>
<behavior name="ID_CodeService.D_ConversionServiceBehavior">
<servicemetadata httpgetenabled="True">
<servicedebug includeexceptiondetailinfaults="True">
<datacontractserializer maxitemsinobjectgraph="2147483647">
</datacontractserializer>
</servicedebug>
</servicemetadata>
</behavior>
</servicebehaviors>
<endpointbehaviors>
<behavior name="Behaviors.EndpointBehavior">
<datacontractserializer maxitemsinobjectgraph="2147483647">
</datacontractserializer>
</behavior>
</endpointbehaviors>
</behaviors>
You also need to add the behavior configuration information in end point
<endpoint address="" behaviorconfiguration="Behaviors.EndpointBehavior" binding="basicHttpBinding" bindingconfiguration="BasicHttpBinding_ID_ConContract" contract="ID_ConContract" name="BasicHttpBinding_ID_ConContract">
</endpoint>
Conclusion
There are also other techniques for sending large data with WCF, which I will explain in the next article.