Sunday, November 29, 2009

WCF Hosting

There are several options available when choosing a Service Host for a WCF Service. These include:
  • IIS
  • WAS (Windows Process Activation Services), built into Vista and Windows Server 2008
  • Windows Service (starts and stops with the OS)
The selection of a Service Host does not have any impact on the development process of the WCF Service itself.

Service hosts must do the following:
  1. Instantiate System.ServiceModel.ServiceHost
  2. Add endpoints to the host
  3. Start the host listening
Several notes about host selection:

  • WAS enables hosting of services that do not rely upon HTTP.
  • When hosting in IIS, must choose a binding that specifies HTTP as the transport, such as basicHttpBinding, wsHttpBinding, wsDualHttpBinding. Choosing a binding based on a different transport causes an error.
WCF supports an ASP.NET Compatibility mode, which allows ASP.NET to provide the hosting environment (and thus the service can get to ASP.NET implicit objects and methods). In order to enable compatibility mode, two things must be done:
  1. aspNetCompatibilityEnabled attribute of must be set to true
  2. AspNetCompatibilityRequirements must be set to Allowed at Service Behavior level.

No comments:

Post a Comment