Friday, May 6, 2016

WCF Part 7 : WCF Binding










WCF Part 6 : WCF Hosting

WCF Hosting


  • IIS Hosting
  • Self Hosting
  • WAS Hosting
  • Windows Service Hosting
IIS Hosting

  • Advantage of hosting a service in IIS
  • Automatically launches the host process when it gets first client request.
  • Uses features of IIS like Process Recycling, Idle shutdown, Process health monitoring, Message based activation
Disadvantage
  • Only Supports HTTP Protocol
Tips : While creating service , choose Http as location in VS new project.

Self Hosting

We make a Host service, keep it running and another application as client which consumes service. It can be any application like console or win form.

Windows Activation Hosting

It is available with windows vista and above. It is available with IIS7.0 and supports Http, TCP and named Pipes.
Hosting WCF in Activation service takes many advantages such as process recycling, isolation, idle time management and common configuration system. WAS hosted service can be created using following steps Enable WCF for non-http protocols Create WAS hosted service Enable different binding to the hosted service

Wednesday, May 4, 2016

WCF Part 5 - Architecture


Architecture

   


Contracts

Contracts layer are next to that of Application layer. Developer will directly use this contract to develop the service.

Service contracts

Describes about the operation that service can provide. 
Example, Service provided to know the temperature of the city . It will be created using Service and Operational Contract attribute.

Data contract

It describes the custom data type which is exposed to the client. This defines the data types, are passed to and from service. 

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.

Policies and Binding

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

Service Run-time

- It contains the behaviors that occur during runtime of service.
  • Throttling Behavior- Controls how many messages are processed.
  • Error Behavior - Specifies what occurs, when internal error occurs on the service.
  • 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.
  • Dispatch Behavior - Controls how a message is processed by the WCF Infrastructure.

Messaging

- Messaging layer is composed of channels. A channel is a component that processes a message in some way, for example, by authenticating a message. A set of channels is also known as a channel stack. Channels are the core abstraction for sending message to and receiving message from an Endpoint. 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 service 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) 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).