Sunteți pe pagina 1din 4

Understanding WCF Bindings and Channel Stack

Author: Imran Abdul Ghani Blog: http://wcfanswers.blogspot.com/

In order to understand WCF Bindings in details, its important to understand the Channel Stack as part of WCF runtime. WCF binding is composed of binding elements and each binding element is corresponding to a specific channel in Channel Stack. The Channel Stack can be categorized into two major areas i.e. Protocol Channels and Transport Channels. Protocol Channels are Transaction Protocol, Reliable Messaging Protocol and Security Protocol while Transport Channels includes Message Encoding and Transport Protocol. Transaction flow is the optional element that enables to specify a protocol flow for incoming transactions and interrupt the transaction flow at certain points. Reliability is also the optional element specifies sending and receiving channels for reliable sessions. Security is another element that specifies features such as authorization, authentication, protection, and confidentiality. Encoding is the required message encoding element specifies text, binary, or MTOM message encoding methods. Transport is also required transport element specifies one of the available protocols i.e. TCP, NamedPipes, HTTP, HTTPS, MSMQ, or Peer-to-Peer or we can define our own custom one.

http://wcfanswers.blogspot.com/

Page 1

Each request coming from the client will go through Channel Stack from top to bottom and then encoded byte stream message will travels over wire. On the other end, message travel from bottom to top and reaches the service as shown in above diagram.

Understanding WCF Bindings and Channel Stack


A complete picture of WCF runtime with Service Instance, Dispatcher and Channel Stack is as follows:

WCF is extensible, so we can defined our own bindings but there are different built-in bindings available in WCF, each designed to fulfill some specific need

1. 2. 3. 4. 5.

basicHttpBinding wsHttpBinding netNamedPipeBinding netTcpBinding netPeerTcpBinding

http://wcfanswers.blogspot.com/

Page 3

For example, if interoperability is critical and we must communicate with non-WCF systems, we can go for basicHttpBinding or wsHttpBinding. If we know the service can reside on a single computer, the netNamedPipeBinding will be the most efficient. If we need to communicate across computers, netTcpBinding or netPeerTcpBinding might work well. And if the service requires support for disconnected or queued calls, we must use a binding that supports Microsoft Message Queue (MSMQ). Finally an important thing to note is, if at all possible, tries to customize an existing standard binding rather than creating a custom binding because creating new one will add the complexity to our solution.

S-ar putea să vă placă și