Wednesday, September 30, 2015

Self Hosting Code in WCF

class Program
    {
        static void Main(string[] args)
        {
       
            Type srvcinfo=typeof(Greet);
            //Create a URI to serve as the base address
            // Address as well binding
            Uri uri=new Uri("https://localhost:8086/Myservice");

 //Create ServiceHost         
            ServiceHost host=new ServiceHost(srvcinfo,uri);

 //Add a service endpoint  

            host.AddServiceEndpoint(typeof(IGreet), new WSHttpBinding(), "ws");

//Start the Service    

            host.Open();
            Console.WriteLine("Hosted the service");
            Console.Read();


        }
    }

No comments:

Post a Comment