WCF

WCF Examples

WCF

WCF Projects

WCF Project

adplus-dvertising
WCF Architecture
Previous Home Next

There are five layers:

  1. Application
  2. Contracts
  3. Service Runtime
  4. Messaging
  5. Activation and hosting
Contracts

Contracts layer are second layer of the wcf architecture. Developer will directly use this contract to develop the service. We are also going to do the same now.

  1. Service contract :

    It explains about the operation that service can provide.

  2. Data contract:

    It explains the custom data type which is exposed to the client and defines the data types, are passed to and from service. Data types like int, string are identified by the client because it is already mention in XML schema definition language document, but custom created class or datatype cannot be identified by the client e.g. Employee data type. By using DataContract we can make client aware that we are using Employee data type for returning or passing parameter to the method.

  3. Message Contract:

    Default SOAP message format is provided by the WCF runtime for communication between Client and service. If it is not meeting your requirements then we can create our own message format. This can be achieved by using Message Contract attribute.

  4. Policies and Binding:

    Itspecify conditions required to communicate with a service e.g security requirement to communicate with service, protocol and encoding used for binding.

Service Runtime

It contains the behaviors that occur during runtime of service.

  • Error Behavior: Specifies what occurs, when internal error occurs on the service.
  • Dispatch Behavior: Controls how a message is processed by the WCF Infrastructure.
  • Throttling Behavior: Controls how many messages are processed.
  • Metadata Behavior: Tells how and whether metadata is available to outside world.
  • Instance Behavior: Specifies how many instance of the service has to be created while running.
  • Transaction Behavior: Enables the rollback of transacted operations if a failure occurs.
Messaging

It is composed of channels and  channel is a component that processes a message in some way, for example, by authenticating a message. Channels are the core abstraction for sending message to and receiving message from an Endpoin and  set of channels is also known as a channel stack.t. Broadly we can categories channels as

  • Transport Channels: Handles sending and receiving message from network. Protocols like HTTP, TCP, name pipes and MSMQ.
  • Protocol Channels: Implements SOAP based protocol by processing and possibly modifying message. E.g. WS-Security and WS-Reliability.
Activation and Hosting

Services can be hosted or executed, so that it will be available to everyone accessing from the client. WCF serv ice can be hosted by following mechanism

  • IIS: Internet information Service provides number of advantages if a Service uses Http as protocol. It does not require Host code to activate the service, it automatically activates service code.
  • Windows Activation Service(WAS): It is the new process activation mechanism that ships with IIS 7.0. In addition to HTTP based communication, WCF can also use WAS to provide message-based activation over other protocols, such as TCP and named pipes.
  • Self-Hosting: WCF service can be self hosted as console application, Win Forms or WPF application with graphical UI.
  • Windows Service: WCF can also be hosted as a Windows Service, so that it is under control of the Service Control Manager (SCM)
Previous Home Next