如何获得Web服务的状态 [英] How to get status of web service

查看:103
本文介绍了如何获得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服务的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆