Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

Transferring large data over the wire using WCF

Joydip Kanjilal | Aug. 31, 2015
Take advantage of the streamed transfer mode to transfer large amounts of data using WCF

</binding>

</basicHttpBinding>

At the client side, you should set the maxBufferSize, maxBufferPoolSize, and the maxReceivedMessageSize properties appropriately. You should also set the appropriate endpoint behavior in the service configuration file as shown below.

<endpointBehaviors>

            <behavior name="IDGEndPointBehavior">

                <dataContractSerializer maxItemsInObjectGraph="2147483647" />

            </behavior>

</endpointBehaviors>

You should also set the maxRequestLength property to a higher value to ensure that the request persists for a longer period. The code snippet that follows shows how you can configure this in the service configuration file.

<system.web>   

<httpRuntime maxRequestLength="102400" />

</system.web>

Note that you should enable the MTOM message encoding by setting the "MessageEncoding" property to "Mtom" when sending large data over the wire - this message encoding would also facilitate interoperability.

Now, let's understand the downsides of streaming too. The streamed mode isn't that secure (it doesn't support reliable messaging) and is not that scalable for high traffic situations. A better solution is chunking -- it can support reliable messaging and can support both message and transport security. Note that you can secure the communication between your WCF service and client by using either Transport Security or Message Security. While the former is used to enforce security at the transport level, the latter is used to encrypt the message that is passed between the WCF server and the client. Hence, chunking is an ideal solution for transferring huge data over the wire using WCF in high data traffic scenarios. You can learn more on this from this MSDN article.

 

Previous Page  1  2 

Sign up for CIO Asia eNewsletters.