Quantcast
Channel: DotNetCrack - WCF
Viewing all articles
Browse latest Browse all 10

Channels in WCF

$
0
0

Channels
A channel is the medium through which messages are exchanged. The channel is created by the client specifying the address of the service and the type of channel to create. Once this information is established, the channel is created and opened.

       Channel a medium through which all messages pass to and from WCF applications.

       It is responsible for preparing and delivering messages in a consistent way.

       Channels are defined for transports protocols and message interception.

       It is created by the client specifying the address of the service and the type of channel to create.

Below Figure illustrates the steps taken when creating a channel and sending a message.

The steps are defined in order as follows:

1.      The client establishes a channel to the service

2.      The service accepts the client’s request to open a channel

3.      The client sends the message request via the channel

4.      The service sends a reply to the client via the channel

Also, once the communication done, it is the responsibility of the client to close and dispose of the channel.

Channel Stacks

       Channels are layered together to create a Channel Stack.

       The goal of a channel stack is to transform a message into a wire format compatible with the sender and receiver and to transport the message.

There are two types of channels that are used to do this:

1.      Transport channels: Transport channels always sit at the bottom of the channel stack and are responsible for transporting messages using a transport protocol. WCF provides a number of transport protocols, including HTTP, TCP, MSMQ, peer-to-peer, and named pipes.

2.      Protocol channels: Protocol channels reside on top of other channels; they are often referred to as layered channels. Protocol channels are responsible for implementing wire-level protocols by transforming and modifying messages. WCF provides many types of protocol channels. Examples include protocol channels that implement support for security, transactions, and reliable messaging.

Role of Protocol Channels

a)      At the top of the stack are the protocol channels.                                                        

b)      Protocol channels interact with a message and facilitate security, reliable messaging,   transactions, and logging features.

c)      There can be any number of protocol channels in a channel stack, depending on the required features.

Role of Transport Channels

a)      Transport channels are responsible for sending bytes over a transmission protocol such as TCP or HTTP.

b)      They are also responsible for using an encoder to convert messages into an array of bytes for transport.

c)      It is the job of an encoder to convert a message from its XML representation to an array of bytes. Encoders are exposed to the transport channel using binding elements.

d)      Transport channels look in the binding context for an implementation of a MessageEncoder class. If none are available, the transport channel can specify a default message encoder.


Viewing all articles
Browse latest Browse all 10

Trending Articles