Articles → WCF → Hosting WCF on IIS

Hosting WCF on IIS
























Software requirement





Prerequisite knowledge















Steps of execution















Benefit of hosting a service on IIS over console application





Create a new WCF service





Click to Enlarge







using System.ServiceModel;

namespace WCFService
{
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        string GetData(int value);        
    }    
}




namespace WCFService
{
    public class Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
        
    }
}





Host it on IIS





Click to Enlarge




Click to Enlarge




Click to Enlarge




Click to Enlarge




Click to Enlarge




Click to Enlarge




Check if service is hosted correctly on IIS











Click to Enlarge






Click to Enlarge




Click to Enlarge




Create a new client application





Click to Enlarge




Click to Enlarge



using System;
namespace WCFClient
{
    class Program
    {
        static void Main(string[] args)
        {
            ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
            Console.WriteLine(proxy.GetData(1));
            Console.ReadKey();
        }
    }
}



Output





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, July 25, 2013

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250