Creating your first WCF Service Hosted in IIS (5.1) on Windows XP Pro SP2

As mentioned in a previous post, I was inspired to begin investigation on creating my first WCF Service hosted in IIS.
After following the steps I remembered from Rob‘s presentation at the Edmonton .NET User Group meeting Thursday last, I was still unable to get the service to properly generate a WSDL file.
Here are the steps I implemented to get the service up and running: 
  1. Install Microsoft .NET 3.0 Redistributable Package.
  2. Install Microsoft Windows Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components.
  3. Install Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP.
  4. Create a project folder and create a virtual directory to your project folder in IIS.

    * Note: Ensure that, if you have multiple versions of the .NET Framework installed on your machine, that you set the ASP.NET version for the virtual directory to 2.0.50727.

  5. Create a new Class Library project and add a reference to ServiceModel.

    * Note: I found it convenient to change the Output path (see attached screenshot) to be bin/ instead of bin/Debug/ as the services work only if the assembly is located in the bin folder, not in any subfolders. I was getting an HTTP 404 "File not found" error when the assembly was being output to the Debug folder.

  6. Create the service class and decorate it with the ServiceContractAttribute.
  7. Decorate the exposed methods with the OperationContractAttribute.

    using System.ServiceModel;

    namespace NoticeablyDifferent.Services {



        public class MyFirstService {



            public string SayHello() {

                return "Hello";


  8. Create an Web.config file with the following system.SeviceModel section:

       <behavior name="ServiceMetadataBehavior" >
        <serviceMetadata httpGetEnabled="true" />
      <service name="NoticeablyDifferent.Services.MyFirstService" behaviorConfiguration="ServiceMetadataBehavior">
       <endpoint contract="NoticeablyDifferent.Services.MyFirstService" binding="wsHttpBinding"/>

    * Note: The behavior element is what enables you to generate a WSDL file and proxy class using the address: http://localhost/NoticeablyDifferent.Service/NoticeablyDifferentServices.svc?wsdl

  9. Create a .svc file (NoticeablyDifferentServices.svc) located in the root application (virtual directory) folder containing the following line of code:

    <%@ServiceHost language=c# Debug="true" Service="NoticeablyDifferent.Services.MyFirstService" %>

  10. Run ServiceModelReg.exe /i /x from the command-line to register the WCF ServiceModel in IIS. This was one of the steps I was missing and found the solution in the MSDN article, Deploying an IIS-Hosted WCF Service. Documentation on ServiceModelReg can be found here.

.NET 3.0, here I come!

The first three steps are outlined on the .NET 3.0 Community Site posting, .NET Framework 3.0 has been released!


Leave a Reply

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

You are commenting using your 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