What are the various methods of hosting a WCF service?
There are four common ways, all of which are outlined nicely on MSDN: Hosting WCF Services.
- Hosting in IIS.
- Hosting in WAS.
- Hosting in a Windows service.
- Hosting in an application (aka "self-hosting").
You can host it in an IIS application or in your own executable. Typically the executable would be a windows service application.
Any Windows process can be used to host a WCF service. There are practically no restrictions on this - a process can host multiple WCF services and the same WCF service type can be hosted across multiple processes simultaneously.
From Juval Lowy's book Programming WCF Services, hosting can be provided by
- Microsoft Internet Information Server (IIS)
- Self-hosting within a Windows Forms application, Windows service, or console app
- Windows Activation Service (WAS)
For right now, everything that's been said is correct.
- Hosting in IIS6 only support HTTP protocols and "on-demand" activation
- Hosting in IIS7 / WAS (only on Vista / Server 2008 and up) supports all protocols and "on-demand" activation
- Self-Hosting in a console app or Windows service supports all protocols, but doesn't support on-demand activation (e.g. your service must be up and running all the time, it cannot be magically activated when a request comes in)
What's not been mentioned is what the .NET 4.0 wave later this year (2009) will offer - there's a new add-on server component called Dublin which is said to offer a rich and managed hosting environment for both WCF services as well as WF workflows.
Marc