C#: How to programmatically check a web service is up and running?

I need to create an C# application that will monitor whether a set of web services are up and running. User will select a service name from a dropdown. The program need to test with the corresponding service URL and show whether the service is running. What is the best way to do it? One way I am thinking of is to test whether we are able to download the wsdl. IS there a better way?

Note: The purpose of this application is that the user need to know only the service name. He need not remember/store the corresponding URL of the service.

I need a website version and a desktop application version of this C# application.

Note: Existing services are using WCF. But in future a non-WCF service may get added.

Note: My program will not be aware of (or not interested in ) operations in the service. So I cannot call a service operation.


  1. How to check if a web service is up and running without using ping?
  2. C program-How do I check if a web service is running


this would not guarantee functionality, but at least you could check connectivity to a URL:

var url = "http://url.to.che.ck/serviceEndpoint.svc";

    var myRequest = (HttpWebRequest)WebRequest.Create(url);

    var response = (HttpWebResponse)myRequest.GetResponse();

    if (response.StatusCode == HttpStatusCode.OK)
        //  it's at least in some way responsive
        //  but may be internally broken
        //  as you could find out if you called one of the methods for real
        Debug.Write(string.Format("{0} Available", url));
        //  well, at least it returned...
        Debug.Write(string.Format("{0} Returned, but with status: {1}", 
            url, response.StatusDescription));
catch (Exception ex)
    //  not available at all, for some reason
    Debug.Write(string.Format("{0} unavailable: {1}", url, ex.Message));

I may be too late with the answer but this approach works for me. I used Socket to check if the process can connect. HttpWebRequest works if you try to check the connection 1-3 times but if you have a process which will run 24hours and from time to time needs to check the webserver availability that will not work anymore because will throw TimeOut Exception.

Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                var result = socket.BeginConnect("xxx.com", 80, null, null);
                bool success = result.AsyncWaitHandle.WaitOne(3000,false); // test the connection for 3 seconds
                var resturnVal = socket.Connected;
                if (socket.Connected)
                return resturnVal;

Need Your Help

Javascript: Move caret to last character

javascript word character caret textrange

I have a textarea and when I click in it I want to move the caret to the last character so Something[caret]

WPF - Titled Border

c# wpf xaml

Is there an equivalent in WPF to the Titled Borders that exists in Java's Swing framework? Below is a link that contains a screenshot of what I am looking for, and some very poor ASCII art.