Page Banner

Hosting a WCF service

[fusion_text]To be able to consume a WCF service, it needs to be hosted.

There are multiple options to host a WCF service, and all of them comes with various advantages and disadvantages.

Available hosting options are as follows.

 Hosting Option Description
1Self-HostingHosting using Console Application, Win Forms, WPF Application etc.
2Windows ServiceHosting Using a Windows Service
3IIS – Internet Information ServicesHosting using IIS. By default, supports only HTTP Bindings. Non-HTTP bindings are not supported.
4WAS –  Windows Activation ServicesHosting using IIS and WAS supports all bindings including Non-HTTP like TCP, MSMQ etc.


  1. Self-Hosting

·  Easy Setup

·  Easy Debugging

·  Supports all bindings and protocols

·  Easy control of lifetime of the service using the ServiceHost class

·   Service is available only when service host is running.

·   Does not support message based activation like in IIS

·   Generally used only in development and demonstration phase.


  1. Hosting using Windows Service

·  Can be configured to start automatically with windows

·  Supports all bindings and protocols

·  Can be configured to restart and recover automatically hen failure occurs

·   Writing custom code for hosting.

·   Difficult to debug, as the host process must be attached to debug.


  1. IIS Hosting

·  No code required to host the WCF service, the ServiceHost directive in the .svc file is responsible for creating the instance as and when required.

·  Supports automatic message based activation

·  Automatic process recycling, helps to restart the service when it is not healthy

·   This hosting supports only HTTP bindings, when hosted in IIS 6.



  1. WAS Hosting

·  All the advantages of IIS hosting

·  Supports all types of bindings

·   Need to install WAS separately with WCF Non-HTTP components.