Click here to Skip to main content
15,886,519 members
Articles / Programming Languages / C#

WCF Ping

Rate me:
Please Sign up or sign in to vote.
4.63/5 (5 votes)
28 Jun 2010CPOL4 min read 61.6K   2.9K   25  
A Command-line utility to ping WCF Services
using System;
using System.ServiceModel;

using WCFPing.Lib;

namespace WCFPing.Hosting
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri baseUri11 = new Uri("net.tcp://localhost:1029/Service");
            Uri baseUri12 = new Uri("http://localhost:1030/Service");
            ServiceHost host = new ServiceHost(typeof(Service), new Uri[] { baseUri11, baseUri12 });
            NetTcpBinding binding1 = new NetTcpBinding(SecurityMode.None);
            WSHttpBinding binding2 = new WSHttpBinding(SecurityMode.None);

            host.AddServiceEndpoint(typeof(IService1), binding1, "IService1");
            host.AddServiceEndpoint(typeof(IService1), binding2, "IService1");
            host.AddServiceEndpoint(typeof(IService2), binding1, "IService2");
            host.AddServiceEndpoint(typeof(IService2), binding2, "IService2");
            
            host.AddDefaultMEXEndPoint();
            host.EnablePing();
            host.EnableIncludeExceptionInFaultBehavior();
            host.Open();
            
            Console.WriteLine(host.QueryServiceEndPoints());
            Console.WriteLine("Service Running...");
            Console.ReadLine();
            
            host.Close();
            Console.ReadLine();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions