How to check if a web service is up and running without using ping?

bebojoor picture bebojoor · Apr 18, 2012 · Viewed 51.4k times · Source

How can i check if a method in a web service is working fine or not ? I cannot use ping. I still want to check any kind of method being invoked from the web service by the client. I know it is difficult to generalize but there should be some way.

Answer

The Pig's Ear picture The Pig's Ear · Sep 12, 2013

I use this method and it works fine :

public bool IsAddressAvailable(string address)
{
    try
    {
        System.Net.WebClient client = new WebClient();
        client.DownloadData(address);
        return true;
    }
    catch
    {
        return false;
    }
}