Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

Understanding WCF in Depth - Part 2

4.50/5 (3 votes)
23 Jan 2015CPOL2 min read 8.9K  
Understanding WCF in Depth - Part 2

Prerequisites: Understanding WCF in depth - Part 1

From the previous post, we understood the 2 core components of WCF, viz. Channel Stack and Service Framework.

In this post, we will look at the internal behavior of Channel stack and Service Framework and its components.

First, let us look at the internal components using the Message Flow Diagram which is below:

Message Flow

Message Flow

Service Layer: From the above, the Service Layer or the Service Framework makes the task easier for the developer. Ideally, a developer needs to write a Message class to be passed into the Channel Stack and this again is a tedious task. The Service F/W gives the leverage for the developers to define & decorate service, message and data contracts, thus internally it creates a Message instance for you. So simple, isn’t it.

Proxy & Dispatcher: It’s the responsibility of the proxy component on the client side and dispatcher component on the service side to mediate and translate between the service and the message layers. In short, the proxy component transforms .NET method calls into Message objects, whereas the dispatcher component turns WCF Messages into .NET method calls.

The service looks for the methods exposed by the proxy and uses this to pass a message to the method.

Channel Stack: A valid message instance comes to the Channel stack asking it to perform some operation and transport it then as raw bytes. The Message passes through each Protocol channel allowing them to operate on the message. The Message then arrives to the Encoder, Encoder converts the Message into raw bytes which are ready for transporting then.

The same process occurs in the server side where in the incoming raw bytes of message are then decoded and passed through various protocol channel to produce a valid Message which is then fed to the dispatcher. Dispatcher finds target service endpoint using the destination address and Action property contained in the Message, deserializes the content of the WCF Message into objects. Then the method is invoked.

As of now, we have studied the flow and what happens in the channel stack, we will in brief look at the Binding Elements for the layers above:

Protocol Binding Elements
Protocol Class Element
Transaction Flow TransactionFlowBindingElement <transactionFlow/>
Reliable Messaging ReliableSessionBindingElement <reliableSession/>
Security SecurityBindingElement <security/>

 

Message Encoding Binding Elements
Message Encoding Class Element
Text TextMessageEncodingBindingElement <textMessageEncoding/>
MTOM MtomMessageEncodingBindingElement <mtomMessageEncoding/>
Binary BinaryMessageEncodingBindingElement <binaryMessageEncoding/>

 

Transport Security Binding Elements
Transport Security Class Element
Windows WindowsStreamSecurityBindingElement <windowsStreamSecurity/>
SSL SslStreamSecurityBindingElement <sslStreamSecurity/>

 

Transport Binding Elements
Transport Class Element
HTTP HttpTransportBindingElement <httpTransport/>
HTTPS HttpsTransportBindingElement <httpsTransport/>
TCP TcpTransportBindingElement <tcpTransport/>
Named pipes NamedPipeTransportBindingElement <namedPipeTransport/>
MSMQ MsmqTransportBindingElement <msmqTransport/>
MSMQ MsmqIntegrationBindingElement <msmqIntegration/>
P2P PeerTransportBindingElement <peerTransport/>

In the next post, we will see why endpoint is needed and its components.

Image 2 Image 3 Image 4 Image 5 Image 6 Image 7 Image 8 Image 9

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)