In Focus

WCF - Windows Communication Foundation

This article helps to explain the architecture of WCF - Windows Communication Foundation.

What's WCF

 
WCF stands for Windows Communication Foundation. It is one of the best technologies of Microsoft and is used to build service-oriented applications, or SOA.
 
Service Orientated Applications: SOA
 
Service-oriented Applications: It is an Architectural Design Pattern/Approach for developing distributed and interoperable applications.
 
Service-oriented Architecture

Windows Communication Foundation
Distributed and interoperable applications
A distributed application has parts of the application running in multiple computer nodes. Distributed applications are called ‘Connected systems’ also.
 

WCF Architecture

 
The architecture is explained below in detail.

Windows Communication Foundation
 
Contracts
 
Contracts are useful to build the WCF service application. They define what protocol (binding) the service uses, how the communication will be done, what message exchange format to use, and more.
 
Contracts are basically of four types,
  • Service contract: It is the interface of the WCF service and it tells the outside world what the service can do.
  • Data contract: It defines the data type of the information that will be exchanged between the client and the service, it is the same as get set properties but the difference is that data contract in WCF is used to serialize and deserialize the complex data.
  • Message contract gives you complete control of the type of formatting of the SOAP message parameters.
  • Policy and Binding specify important information such as security, protocol, and other information.
Service Runtime
 
The service runtime layer specifies the various service behaviors that occur during runtime.

List of various behaviors managed by Service Runtime layer,

  1. Throttling Behavior: Controls how many messages are processed.
  2. Error Behavior: Specifies what occurs, when an internal error occurs on the service.
  3. Metadata Behavior: Tells how and whether metadata is available to the outside world.
  4. Instance Behavior: Specifies how many instances of the service have to be created while running.
  5. Transaction Behavior: Enables the rollback of transacted operations if a failure occurs.
  6. Dispatch Behavior: Controls the way by which a message gets processed by the infrastructure of WCF.
  7. Concurrency Behavior: Controls the functions that run parallel during a client-server communication.
  8. Parameter filtering: It filters the message headers and executes preset actions based on the filters of the message headers.
Messaging

This layer defines what formats and data exchange patterns can be used during service communication.

Activation and Hosting
 
This layer of WCF architecture is the place where services are actually hosted or can be executed for easy access by the client. This is done through various mechanisms.
  • IIS
  • Windows Activation Service
  • Self-hosting
  • Windows Service