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

后端 未结 8 961
小蘑菇
小蘑菇 2020-12-30 09:42

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 c

8条回答
  •  一向
    一向 (楼主)
    2020-12-30 10:11

    The only way to know if a web service method is working "fine" is to call the method and then to evaluate whether the result is "fine". If you want to keep a record of "fine" vs. time, then you can log the result of the evaluation.

    There's no more general way to do this that makes any sense. Consider:

    1. You could have code that creates an HTTP connection to the service endpoint, but success doesn't tell you whether the service will immediately throw an exception as soon as you send it any message.
    2. You could connect and send it an invalid message, but that doesn't tell you much.
    3. You could connect and send it a valid message, then check the result to ensure that it is valid. That will give you a pretty good idea that when a real client calls the service immediately afterwards, the real client should expect a valid result.
    4. Unless the service takes that as an opportunity to crash, just to spite you!

    The best technique would be to use WCF tracing (possibly with message-level tracing) to log what actually happens with the service, good or bad. A human can then look at the logs to see if they are "fine".

提交回复
热议问题