WCF Services: Types of Service Hosting

Description Article
Table of Contents
Summary

WCF supports multiple hosts and protocols.

Description

The host avalable protocols must considerer the following issues:

  • Availability: When does the service must be reached ?
  • Reliability: What happens when the service somehow breaks and how does this affect service consumers?
  • Manageability: Easy access to information is required about what is happening on the host where WCF services live?
  • Versioning: Does old versions of the service must be supported and who is consuming the services ?
HOSTING ENVIRONMENT SUPPORTED PROTOCOL CATEGORY
Windows console and form application HTTP, net.tcp, net.pipe, net.msmq Self-hosting
Windows service application (formely known as NT services) HTTP, net.tcp, net.pipe, net.msmq Windows Service hosting
Web server IIS6 HTTP IIS hosting
Web server IIS7 – Windows Process Activation Service (WAS) HTTP,net.tcp, net.pipe, net.msmq Windows Activation Service (WAS)

Summary of hosting options and supported features:

FEATURE SELF-HOSTING WINDOWS SERVICE HOSTING IIS HOSTING WAS HOSTING
Executable Process/ App Domain Yes Yes Yes Yes
Configuration App.config/programatically App.config/programatically Web.config Web.config
Activation Manual at startup Manual/automatic at startup Message-based Message-based
Idle-Time Management No Yes Yes Yes
Health Monitoring No Yes Yes Yes
Process Recycling No Yes Yes Yes
Management Tools No Yes (Service Control Manager) Yes Yes
Operations
Self hosting

Advantages

  • Easy to use: Few lines of code required to make the service running
  • Flexible: The lifetime of the services is easily controled through the Open() and Close() methods of ServiceHost
  • Easy to debug: No attach to separate application process is required
  • Easy to bind: Supports all bindings and transport protocols

Disadvantages

  • Limited avalability: The service is reachable only when the application is running/li>
  • Limited features: Easy manageability, robustness, recoverability, versioning, and deployment scenarios are not available
Windows Service hosting

Advantages

  • Automatic starting: The Windows Service Control Manager allows to set the startup type to automatic
  • Recovery: The Windows Service Control Manager has built-in support to restart services when failures occur
  • Security identity:: The Windows Service Control Manager allows to choose a specific security identity under which the service to run including built-in system or network service accounts
  • Easy to bind: Supports all bindings and transport protocols

Disadvantages

  • Deployment: Services must be installed with the .NET Framework Installutil.exe utility
  • Limited features: Easy manageability, robustness, recoverability, versioning, and deployment scenarios are not available

IIS hosting

Advantages

  • Automatic activation: IIS provides automatic activation when an HTTP request is received that means the service is not necessary to be running in advance. When any message is received by the service it then launches and fulfills the request
  • Process recycling: Recycling process exists

Disadvantages

  • Limited binding: Supports only HTTP-related bindings and transports protocols
  • Address: Services addreses must end with the “.svc” entension