本文介绍了如何获得Web服务的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能得到Web服务的使用C#的状态?无论是成功完成,失败或挂起这样的。
How can I get the status of web service using C#? whether it is completed successfully, failed or pending like this.
推荐答案首先,我发现这个问题的 Web服务数据库/网站状态
First i found this question Web Service For Database/Website Status
你应该试试这个code;
And you should try this code;
System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("myService"); return sc.Status和您应该检查这个code;
And you should examine this code;
public static string PingHost(string args) { HttpWebResponse res = null; try { // Create a request to the passed URI. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(args); req.Credentials = CredentialCache.DefaultNetworkCredentials; // Get the response object. res = (HttpWebResponse)req.GetResponse(); return "Service Up"; } catch (Exception e) { MessageBox.Show("Source : " + e.Source, "Exception Source", MessageBoxButtons.OK); MessageBox.Show("Message : " + e.Message, "Exception Message", MessageBoxButtons.OK); return "Host Unavailable"; } },你也应该看看;
And also you should look;
使用会话状态在Web服务
更多推荐
如何获得Web服务的状态
发布评论