WCF - Architecture
WCF - Architecture
- WCF contains a layered architecture with support for the distributed application development.
- The architecture has four major layers such as Contracts, Service runtime, Messaging, Activation and Hosting.
- The above diagram depicts an inner view of each layer.
- Contracts layer stay close to the application and hence developers directly communicate with this layer.
- Hence its duty is to define the service in detail and delegate access methodologies to acquire the service.
- The features of contracts layer includes:
Data Contract :
- Data Contract describes the message parameter (ie.) the data passed to and received from the service.
- These parameters are well-defined by XML Schema definition language (XSD) documents.
- This enables any system, that understands the XML and to process the documents.
Message Contract :
- Message Contract defined as the parts of using SOAP message format.
- It is used to control these message parts during the interoperability process.
Service Contract :
- Service Contract clarifies more on the method definitions of the service.
- It is available in the form of interface defined by Visual Basic or Visual C# and provide details on service endpoints for easy communication with the service.
Policies and Bindings :
- It informs about the conditions that needs to be followed for communicating with a service.
- It comprises of security measures needed for establishing communication.
Service Runtime :
- Service runtime layer defines the service behaviors during its actual operation. Some of them are listed as follows:
- Throttling takes care on the number of messages to be processed at a time. The count varies with the demand for the service.
- An error behavior outputs an internal error on the service, to the client.
- Metadata concerns much about the metadata’s availability to the client.
- Instance Behavior decides on the number of instances of the service at a particular time.
- Transaction Behavior takes care of rolling back a process to its previous state in case of failures.
- Dispatch Behavior insist more on the processing of message by the WCF architecture
- Concurrency Behavior selects the method for switch over mechanism via the threading process.
- Parameter Filtering filters the message headers and completes the preset actions with the filters as base.
Channel Stack in WCF messaging
- Message contains a set of channels termed as channel stack and to process the upcoming messages.
- Two types of channels are as follows.
Transport Channels :
- Available at the bottom of the stack.
- Communicate messages with the network via HTTP, named pipes, TCP, and MSMQ.
- Use encoder schemes such as XML and optimized binary.
Protocol Channels :
- Present at the top of channel stack.
- Process message header via protocols such as WS-Security and WS-Reliability.
Activation and Hosting :
- Services are hosted or executed for the client’s usage. The activation and hosting mechanisms:
- IIS(Internet information Service) automatically activates the service code in case of a service using Http Protocol.
Windows Activation Service :
- WAS is the process activation tool that is available as part of IIS 7.0.
- It is used to provide message-based activation on protocols such as TCP and named pipes.
- A WCF service is made to be self-hosted either as a console application or a Windows Application or as a WPF application.
Windows Service :
- WCF can be hosted as a Windows Service, and controlled by the Service Control Manager (SCM).