Being a Good Host

Hosting a WCF application is quite simple. There are 3 available hosting options IIS (Internet Information Services), WAS (Windows Activation Service) under Vista/Server 2008 and an ordinary (windows form/console) application.

The quickest to getting your project up and running is a windows form (or console) app. This way you can begin development quickly.

//program.cs
static class Program
{
   [STAThread]
   static void Main()
   {
      Application.Run(new FormWcfHost());
   }
}

Then for the windows form:

public partial class FormWcfHost : Form
{
   private ServiceHost<MyService> serviceManager 
      = new ServiceHost<MyService>();

   public FormWcfHost()
   {
      serviceManager.Open();
   }
		
   private void FormWcfHost_FormClosed(object sender, 
       FormClosedEventArgs e)
   {
      serviceManager.Close();
   }
}

It’s that simple.

The production level hosting decissions are just slightly more involved. Basically if you have an installation of Windows 2008 Server available then it’s ideal to make use of WAS to host it. Otherwise the choice can be argued between IIS6 hosting or just running it as a standard windows service on a Windows 2003 depolyment.

The advantages that WAS offers are; application pooling, isolation, identity management. So is the more scalable choice.

Advertisements

One thought on “Being a Good Host

  1. […] Client configuration leads onto the topic of hosting the WCF service which will be the next post “Being a Good Host“. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s