0

I have about 500 web services. I tired to use Ping but it dont seem to be accurate. I have tested web client and download to string. Using stopwatch i calculated the download time. Its also not so accurate. What is the best method to identify the availability of the web service?

Stopwatch sw = new Stopwatch();
sw.Start();
pingable = a.IsAddressAvailable(nameOrAddress);
sw.Stop();

public bool IsAddressAvailable(string address)
{
    try
    {
        System.Net.WebClient client = new WebClient();
        client.DownloadData(address);
        return true;
    }
    catch
    {
        return false;
    }
}
MethodMan
  • 18,625
  • 6
  • 34
  • 52
Kanes
  • 105
  • 1
  • 10
  • Possible duplicate of [C#: How to programmatically check a web service is up and running?](http://stackoverflow.com/questions/12094024/c-how-to-programmatically-check-a-web-service-is-up-and-running) – MethodMan Jan 11 '16 at 19:02

2 Answers2

0

You can create an Endpoint returning the status of your services. You can call this particular webservice time to time to check availability. If the server dont answer for a predetermined number of retries) you can consider it Down.

Its a webservice to check server and services status.

0

You will need to think about setting up a healthcheck strategy.

Depends on the layer, you want to check:

Network availability? Ping should be enough, as long as the ICMP packets are not rejected on their way by any firewall. Maybe not a really meaningful test.

Socket/application server availability? A simple recurring socket connection check (for examples, see Java detect lost connection) is the most efficient way of checking, if there is a listener up and running on your application server. But in some cases, this test is not enough in case the http server of your webservice is up and running, but your webservice has for instance issues behind (database problems for instance)

Functional availability? The most reliable but also most complex strategy. You will need to a) implement a ping service on the soap-layer of your webservice or b) invoke existing webservice operations for checking their availability. But, you must be careful when invoking writing services. Either you design them in an idempotent manner (retries/duplicate requests don't change anything), or you prepare some functional harmless invalid request towards your write services and make an assert on your healtcheck-client against the response.

Community
  • 1
  • 1
Aydin K.
  • 3,309
  • 36
  • 44