What is a Channel in WCF?


In a Service oriented architecture, there are two parties involved, Server and Client. The server and client communicate to each other via Messages. Messages  travel over the network. For communication; server and client must be agree upon:

  1. Format of message
  2. Protocol
  3. Transport
  4. Encoding of the message etc.

Channels are the responsible component of WCF for

  1. Creation of consistent message
  2. Transport of consistent message.
  3. Conversion of Message in wire format

    WCFChn1.gif

The main goal of a Channel is to transform messages to a format understandable by the communication wire and compatible to both the server and client and then transport the message over the wire in between the  client and server.

WCFChn2.gif

Essentially, a Channel has to make decision about:

  • Protocol used in the message
  • Encoding in the message
  • Message is reliable or not
  • Security of the message
  • Transaction of the message

Mainly a channel performs two different types of task and on basis of the task, the channel is of two types,

WCFChn3.gif

Transport channels are responsible to send and receive the message using a transport protocol. WCF supports HTTP, TCP, and MSMQ, Peer to Peer and Named Piped transport protocols.

Protocol channels are responsible for implementing and supporting security, transaction and reliable messaging. These channels transform and modify the message to make it compatible to wire level.

In a communication, there may be one or more than one transport and protocol channels. Collections of different channels are called as Channel Stack.

Different channels perform different tasks. For example, one protocol channel can secure the message whereas another protocol channel can make message reliable.

In the WCF architecture, the transport channel always resides at the bottom of channel stack. A usual channel stack can be depicted as below,

WCFChn4.gif

WCF provides us with many readymade channel stacks to do communication between services and clients. These WCF provided channel stacks are known as Binding. One channel layer is defined by one Binding Element.

WCFChn5.gif

You are very much allowed to create your own channel stack if none of the WCF provided bindings meet your requirements.

The transport protocol of services and clients communicate to each other.

WCFChn6.gif

The transport channel converts messages into bytes or binary to send over the network. Encoding of messages is also done by the transport channel.

I hope you are having basic idea about channels now. Thanks for reading.

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Up Next
    Ebook Download
    View all
    Learn
    View all