WCF Architecture

This article helps to explain the architecture of WCF and the components that make WCF what it is.

This article helps to explain the architecture of WCF and the components that make WCF what it is.
 

Introduction

 
Windows Communication Foundation (WCF) is a platform or a framework for creating and distributing connected applications. Built on top of the 2.0 .NET Framework CLR, the WCF is a set of classes that allows developers to build service-oriented applications.
 

Getting Started

 
At the heart of WCF is a layered architecture that supports a lot of the distributed application development styles. There are four major layers that provide developers a new service-oriented programming model. The following image shows the various layers and their components.
 
1.jpg 
 

Layer 1:  Contracts

 
WCF contracts are much like a contract that you and I would sign in real life. This contract or WCF contract contains information such as what a service does and the type of information it will make available. A WCF Contract is a collection of Operations that specifies what the Endpoint communicates to the outside world. There are four types of contracts.
  1. Data contract explicitly stipulates the data that will be exchanged by the service.
  2. Message contract controls the SOAP messages sent and received by the service.
  3. Service contract is what informs the clients and the rest of the outside world what the endpoint has to offer and communicate.
  4. Policy and Binding contracts specify important information such as security, protocol and other information.

Layer 2:  Service Runtime

 
This layer specifies and manages the behaviors of the service that occur during service operation.
 
List of various behaviors managed by Service Runtime layer:
  1. Throttling Behavior determines the number of processed messages.
  2. Error Behavior specifies what action will be taken if an error occurs during service runtime.
  3. Metadata Behavior controls whether or not metadata is exposed to the outside world.
  4. Instance Behavior drives how many instances of the service will be available to process messages.
  5. Message Inspection gives the service the ability to inspect all or parts of a message.
  6. Transaction Behavior has the ability to rollback the transaction, if a process fails during the service runtime.
  7. Dispatch Behavior service determines how the message is to be handled and processed.
  8. Concurrency Behavior determines how each service, or instance of the service, handles threading.
  9. Parameter Filtering filters the message headers and executes preset actions based on the filter of the message headers.

Layer 3:  Messaging

 
This layer defines what formats and data exchange patterns can be used during service communication.
 
Following lists the channels and components that the Messaging layer is composed of:
  1. WS Security Channel implements the WS-Security specification, which enables message security.
  2. WS Reliable Messaging Channel which provides guaranteed message delivery.
  3. Encoders let you pick from a number of encodings for the message.
  4. HTTP Channel tells the service that message delivery will take place via the HTTP protocol.
  5. TCP Channel tells the service that message delivery will take place via the TCP protocol.
  6. Transaction Flow Channel governs transacted message patterns.
  7. NamedPipe Channel enables inter-process communication.
  8. MSMQ Channel helps to use MSMQ.

Layer 4:  Activation and Hosting

 
This layer provides various options in which a service can be started as well as hosted. Services can be hosted within the context of another application, or they can be self-hosted. The following list details the hosting and activation options provided by this layer:
  1. Windows Activation Service enables WCF applications to be automatically started when running on a computer that is running the Windows Activation Service.
  2. .EXE, WCF allows services to be run as executables.
  3. Windows Services, WCF allows services to be run as Windows service.
  4. COM+, WCF allows services to be run as COM+ application.
Reference
 
Professional WCF Programming Book by Scott Klein.
 

Conclusion

 
Hope this article helps you to understand WCF Architecture. Please post your comments.
 
Read more: