WCF Streaming – Easy WCF
Skip to content

WCF Streaming

In this article, we will discuss on WCF streaming and why is it required?

Client and Service exchange message using Streaming transfer mode, receiver can start processing the message before it is completely delivered.

Streamed transfers can improve the scalability of a service by eliminating the requirement for large memory buffers. If you want to transfer large message, streaming is the best method.

I/o Streams:

WCF uses .Net stream class for Streaming the message.

Stream in base class for streaming, all subclasses like FileStream,MemoryStream, NetworkStream are derived from it.

Stream and it’s subclass can be used for streaming, but it should be serializable. MemoryStream are serializable and it will support streaming but Filestream are not.

Stream the data, you need to do is, to return or receive a Stream as an operation parameter.

 

Streaming and Binding:

  • Supported bindings are:
    • BasicHttpBinding
    • NetTcpBinding
    • NetNamedPipeBinding

 

  • TCP, IPC and HTTP bindings support streaming.
  • For all the Binding streaming is disabled by default.
  • Streaming of the message should be enabled in the binding to override the buffering and enable the streaming.
  • TransferMode property should be set according to the desired streaming mode in the bindings.
  • Type of TransferMode property is enum TransferMode

 

StreamedRequest – Send and accept requests in streaming mode, and accept and return responses in buffered mode
StreamResponse – Send and accept requests in buffered mode, and accept and return responses in streamed mode
Streamed – Send and receive requests and responses in streamed mode in both directions
Buffered -Send and receive requests and responses in Buffered mode in both directions

 

Configuring Streaming in Config file :

 

Increasing Message Size:

The default message size is 64K. But the message size in case of streaming may be very large. So default message size could be increased.
MaxReceivedMessageSize property of BasicHttpBinding class is used to increase the message size. Typical way of increasing message size is in config file.

 

Restriction on Streaming:

1. Digital signatures for the message body cannot be performed
2. Encryption depends on digital signatures to verify that the data has been reconstructed correctly.
3. Reliable sessions must buffer sent messages on the client for redelivery if a message gets lost in transfer and must hold messages on the service 4. before handing them to the service implementation to preserve message order in case messages are received out-of-sequence.
5. Streaming is not available with the Message Queuing (MSMQ) transport
6. Streaming is also not available when using the Peer Channel transport

© 2015, admin. All rights reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *