Thursday, March 03, 2011

Walkthrough on creating WCF 4.0 Service and Hosting in IIS 7.5

Objective
This article will give step by step walkthrough

  • How to create a basic WCF 4.0 Service?
  • How to host WCF Service in IIS 7.5?
  • Hot to test service in a client.

Create WCF Service

Create WCF service. Open visual studio select new project and then from WCF tab select WCF Service application to create a new WCF service.
http://beyondrelational.com/images/service_and_hosting_iis.bmp

Delete the default code created by WCF from IService1 and Service1.svc.cs

a. So delete the data contract
b. Modify the service contract as below. Just make one operation contract to return a string .

IService1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService5
{
   [ServiceContract]
   public interface IService1
   {
       [OperationContract]
       string GetMessage();
     
   }  
}

Read more: Beyond Relational