WCF - Architecture

WCF is a layered architecture. Below diagram give you an overview of windows communication foundation(WCF) architecture.

WCF Architecture

WCF contracts defines the operations available in the address(endpoint) that communicate to the outside world. Four types of contacts available in WCF they are Service Contract, Data Contract, Message Contract and Policy and Binding.

  • Service Contract: Defines what the service provides to the client through endpoint.
  • Data Contract: Defines each parameter/data type in every message that a service create or consume.
  • Message Contract: Defines how messages to be structured. Default SOAP message format is applied to service for client and service communication.
  • Policies and Bindings: Defines conditions like how a client should communicate with a service like transport used http or tcp, encoding and other security requirements.

Service runtime:
Service runtime layer contains the behavior of the service that occurs during run time. Below are the different types of service runtime behaviors.

  • Throttling Behavior: Controls the number of messages are processed.
  • Error Behavior: Handles internal service errors.
  • Metadata Behavior: Defines the availability of meta data to client/outside world.
  • Instance Behavior: Specifies how many instances of the service can run
  • Transaction Behavior: Rollback the transacted operations when failure occurs.
  • Dispatch Behavior: Defines how the message is processed.

This layer defines the formats and data exchange during service communication. The types of channels in messaging is Transport Channels and Protocol Channels.

  • Transport Channels: Read and write messages from network transports like http, name pipes, tcp and msmq.
  • Protocol Channels: Implement SOAP base protocols, often reading or modifying additional headers to the message.

Activation and hosting:
WCF service can be hosted in multiple ways. Self hosting, IIS hosting, WAS hosting, Windows service hosting.

  • Self hosting: Hosting in Console or Desktop Application
  • IIS hosting: Hosting in Internet Information Services(IIS)
  • WAS hosting: Hosting in Windows Activation Service
  • Windows service hosting: Hosting in Windows Service

Read more about hosting: http://dotnetlearners.com/wcf/wcf-hosting