Friday, May 20, 2016

Support high volume data transfer by WCF service

Sometime the requirement is send big data to WCF service from client, basically looking for option to send high data through the wire.

WCF can support up to 2 GB data through the wire; even though it is not recommended.

To enable this we need to set some attributes to binding tags in Server and Client side config file

Server Config File
<bindings>
   <wsHttpBinding>
     <binding name="wsHttpBindingSettings" maxReceivedMessageSize="2147483647">
       <readerQuotas
              maxDepth="2147483647"
              maxStringContentLength="2147483647"
              maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
              maxNameTableCharCount="2147483647"/>
      </binding>
   </wsHttpBinding>
</bindings>

<endpoint
address=""
binding="wsHttpBinding"
contract="WcfService1.IService1"
bindingConfiguration="wsHttpBindingSettings">      

Client Config File 

<bindings>
  <wsHttpBinding>
     <binding
name="WSHttpBinding_IService1"
maxBufferPoolSize="2147483647"
              maxReceivedMessageSize="2147483647">
      <readerQuotas
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
     </binding>
  </wsHttpBinding>

</bindings>
   <endpoint
address="http://localhost:59284/Service1.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" 
contract="ServiceReference1.IService1"
       name="WSHttpBinding_IService1">

No comments: