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

后端 未结 8 923
小蘑菇
小蘑菇 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:14

    As I see it, you have 2 options:

    • If you can access the server it is running on, Log every call (and exceptions thrown).
      Read the log file with a soft like baretail that updates as the file is being written.

    • If you can't access the server, then you have to make the webservice write that log remotely to another computer you have access to.
      Popular loggers have this functionality built in. (Log4Net, ...)

    0 讨论(0)
  • 2020-12-30 10:18

    just use try catch inside the method of your webservice and log exceptions to a log file or to the event log. Example:

    [OperationContract]
     public bool isGUID(string input)
    {
        bool functionReturnValue = false;
    
        try
        {
            Guid guid;
            functionReturnValue = Guid.TryParse(input, guid);
        }
        catch (Exception ex)
        {
            Log.WriteServerErrorLog(ex);
        }
    
        return functionReturnValue;
    }
    

    You don't need to ping the webservice, but instead ping the server with a watchdog service or something. There is no need to "ping" the webservice. I also think you don't need to do this anyway. Either your webservice works or it doesn't because of bad code.

    0 讨论(0)
提交回复
热议问题