, ,



This article explains how messages travel from the client application to the service application and what are all the various steps in it and how the developer can extend the process during the message travel. 
Also, I would like to tell you something about the SOA patterns, why and how the SOA Patterns are implemented in WCF. Ok, let’s talk about it.

WCF Runtime Architecture

I am very interested in explaining something about the WCF runtime architecture. It is actually an important and must-know concept for everyone trying to learn about the messaging patterns. It’s a multilayered architecture allowing various types of messaging patterns to be implemented. The data in the multilayered architecture travels from the client application to a stream transporting the message. It travels up to the implementation of the service

                    WCF runtime Architecture

In the preceding figure, you can find the calls passing the proxy layer which actually converts the calls into the messages and sends them through the channel and the dispatcher will get back the calls by converting from the messages.

The proxy layer will continue pushing the messages on the channel, it is passing the protocol and the encoder layers before it is reaching the wires. On the services side, it passes through the encoder and protocol layers and it is received by the dispatcher. Finally, it’s the dispatcher’s responsibility to examine the messages and decide which method to call. In the client-side there are four extensible points before the data travels to the transport stream, the first one is the parameter inspection where you can hook to do the custom validation, value modification, or special filtering. In the next extensible point the proxy leverages is message formatting (serializing) where you convert the calls into the WCF objects. You can also customize the serialization process by using a custom formatter object. And the final extension point is the message inspection and extension. 

In the service side there are five extensible points, here the procedure are completely reversed against the client-side procedure. 

The first extensible point here is the message inspector where it can be used to dispatch runtime programmatically. Then the next step is the operation selector where the dispatcher will select the operation. Once the target has been identified, the dispatcher will deserialize the WCF messages into the objects that can be supplied as parameters when invoking the target method. At this point the dispatcher provides the extension points for the message deserialization and the parameter inspection. The final step for the dispatcher is to invoke the target method, supplying the prepared parameters.

Why SOA patterns are implemented in WCF

Actually the WCF team at Microsoft was trying to deliver by considering the following main points

  •  Interoperability across platforms
  •  Unification of existing technologies
  •  Service oriented programming

Interoperability across platforms: Microsoft wants the application running on Windows to be able to communicate with legacy applications, MAC OS X Machines, Linux machines, Windows clients, Solaris machines and anyone else who abides by the Web Services Interoperability (WS-I) Organization Specification.

Unification of existing technologies: WCF takes all the capabilities of the distributed technologies and overlays a simplified API called System Service Model, in which you can find all things of ASMX, WSE and System.Messaging,. Net Remoting In one roof of WCF.

Service Oriented Programming: To increase the flexibility in the programming Ease the business orientation of modern software projects, WCF takes us Service oriented programming from the Object Oriented Programming.

How SOA Patterns are implemented in WCF

SOA Design Patterns

Establishing a robust service oriented architecture requires the business to take in the account of Design Patterns, Security and API management. SOA design Patterns allow organizations to solve their problem by using the proven solutions.
SOA patterns have the solutions for the commonly recurring problems within the enterprise. The implementation environment for SOA design patterns must allow loose coupling and reuse of integration solutions. We will see in WCF how these patterns are used and why.

Decoupled Contract

The reason why this “Decoupled Contract” has been invented is “How can a service, express its capabilities independently of its technical implementation?”In other words, to provide an effective enterprise service, the technical contract should be completely Independent from its logical implementation which is yet to align with the other services. So only the interface details will be visible to the client, not its implementation.



By decoupling the service contract, the service implementation can be evolved without directly impacting service consumers. This can increase the amount of refactoring opportunities and reusability. 

Proxy Pattern

A Proxy Pattern is used to provide a surrogate object, which references the other object. Also called, it is a proxy class, it represents the functionality of another class.


Let’s discuss how the proxy pattern is applied in WCF. In WCF as soon we create a service reference for a WCF service, a proxy object will be created.

WCF provides the ClientBase<T> for the proxy classes to inherit. The base class has the capability to set up the communication and other operation calls. The consumers send a call against the proxy for which the SOAP messages will be sent to the service using a defined binding. As I said in the preceding source code example, the proxy object provides a surrogate object, servClass, which represents the functionality of another class called ServiceClass. The same concept is being used in the WCF Service and the proxy.

Operation Context Pattern 

It decouples the functional input parameters from the technical information the method needs to execute. WCF provides a method called System.ServiceModel.OperationContext , this class will take over the responsibility of providing information about the call, session id and incoming message header in the SOAP envelope and the information about the identity of the caller. The context contains lots of information about the non-functional and therefore it should not be the part of the DataContract. When working with the duplex mode, operation context provides the channel to be used to call back the client during the method execution. Also the operation context provides an additional context called WebOperationcontext that provides the method and more information about the request in terms of HTTP properties.


The main purpose of WCF is to create interoperability across platforms and unification among the legacy systems. Also the WCF supports the SOA patterns Decoupled, Façade, proxy, operational context patterns to define the system as SOA oriented.