Sunday, 4 May 2008

WCF primer - hosting

This is part two of the WCF primer. The landing page can be found here.

A WCF service can be hosted in three ways, each with their orwn (dis)advantages.

IIS [6.0] hosting

IIS hosting is similar to web services.
IIS 6.0 has two parts, a listener process (w3svc) and a worker (w3wp) process.  The listener process listens (what a surprise) for messages coming in over http and passes them on to the  worker process, which in turn passes it on to the appropriate IIS application.

Two things should be pointed out here

  • url & application mapping
    done via the IIS metabase
  • instance management
    if the application is not yet running, w3svc creates a new instance of the application (living in it's own dedicated w3wp process)

The downside to IIS is that you can only use Http.

WAS hosting

Windows Activation Service (WAS for short) is a part of IIS 7.0 (although it's not installed  by default - figure that one out yourself ). The step up from IIS 6.0 is that IIS 7.0 + WAS support non http endpoints.

Changes from IIS 6.0:

  • IIS metabase has been replaced by applicationhost.config
  • w3svc still listens for messages over Http, but is no longer responsible for instantiation of applications, this is done by the WAS.

WAS components

  • configuration manager
    reads applicationhost.config
  • process manager
    creates new applicaitons
  • unmanaged listener adapter interface
    defines how non Http listeners (Tcp, Named Pipe, Msmq) forward activation requests to WAS.

SMSvcHost
Another service, SMSvcHost,  actually receives the activation requests and forwards them on to WAS.
This services hosts

  • NetTcpPortSharing
    A service that allows tcp ports can be shared between listeners.
  • NetTcpActivor
    WCF tcp activation service, forwards calls to WAS via the listener adapter interface.
  • NetPipeActivator
    WCF named pipe activation service, forwards calls to WAS via the listener adapter interface.
  • NetMsmqActivator
    WCF Msmq activation service, forwards calls to WAS via listener adapter interface.

Self hosting

The third and final way to host a WCF service is to host it within a custom application (any managed process).
The downside to this is that you lose the instance management of IIS/WAS.   This means that you need to create an instance yourself before a call can be successfully handled, whereas IIS/WAS creates the instance for you.
Like WAS, self hosting allows you to service any kind of WCF.

Code examples of this in later posts.

0 comments: