Hosting WCF Service inside IIS

Windows Communication Foundation:

Windows Communication Foundation(WCF) takes many existing communication technologies, such as Web Services, Windows Remoting, Microsoft Message Queuing, and abstracts them into a single technology. In most cases, this simplifies the way you communicate with other applications. It also allows you to communicate with other applications without being coupled to a specific technology. In this we are going to create a simple WCF service and we are going to host that service inside SharePoint 2010 .

Steps Involved:

Create a WCF Service:

The following steps should be followed to create a WCF service using Visual Studio 2010.

I. Open Visual Studio 2010.

ii. Go to File => New => Project.

iii. Select WCF Service Application under installed template category WCF and name it as Wcf.

iv. Target the .Net Framework 3.5.

v. Click OK.

vi. In the Solution Explorer delete Service.svc and IService.cs files.

vii. Right click the Solution Explorer and add a New Item.

viii. Select WCF Service and name it as CustomService.svc.

ix. Replace ICustomerService.cs with the following code.

  1. using System;

  2. using System.Collections.Generic;

  3. using System.Linq;

  4. using System.Runtime.Serialization;

  5. using System.ServiceModel;

  6. using System.Text; 

  7. namespace Wcf

  8. {

  9.     [ServiceContract]

  10. public interface ICustomService

  11.     {

  12.       [OperationContract]

  13. string GetTime();

  14.     }

  15. }

x. Replace CustomerService.svc.cs with the following code.