我想在调用一个webservice之前判断一下这个webservice是否可用,大家有好的建议吗? seePING UTILITY and WEBSERVICE in C# .NEThttp://www.eggheadcafe.com/articles/20020209.asp 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 i.e., try to ping your server to see if it is online, also seehttp://www.csharphelp.com/archives2/archive296.htmlhttp://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1509&lngWId=10 以下是我在windows 服务中去定时调用web service时的判断, 比较稳定用HttpWebRequest会记住状态, 如果IP一次不能访问, 除非重启服务, 否则一直引用MSXML2.dllusing MSXML2;string url = "xxxx";XMLHTTP http = new XMLHTTP();try{ http.open("GET", url, false, null, null); http.send(null); int iStatus = http.status; //如果取得的网页状态不正确, 就是不存在或没权访问 if(iStatus != 200) return -1;}catch(Exception ex){ Console.Write(ex.ToString()); try { EventLog.WriteEntry("xxxxx", url + "不能访问!", EventLogEntryType.Error); } catch{} return -1;} 请问在一个webapplication 怎样使用XMLHTTP对象 webform里也一样使用, 不过EventLog.WriteEntry()这句就别在web上执行了 panyee(快乐王子) :你老哥的方法不行呀,哪个webservice即使可以正常使用http.status的值也不是200,而是500:请求格式无法识别 string url = "http://xxxx/MyWeb/service1.asmx";你是不是这样写的? xmlhttp只是最基本的试探那个页面是否显示正常500是服务器错误403是拒绝访问404页面不存在 url你写的是什么? xmlhttp是探测asmx页面是否正常 string url = "http://xxxx/MyWeb/service1.asmx";我写的就是这个呀 我这里一直那么应用的, 其它机器浏览你的asmx页面是否正常? 帮忙看看这条sql语句 <MM请教孟子一章>正则表达式 问个关于 ActiveXObject 的用法问题 关于读取XML的问题..不是如何读取的问题! 大家说说ActiveX对一个ASP.net开发人员有什么意义。 引用服务端js文件 全局函数,菜鸟问题! 毕设老师BT,学生无奈。在此向各位高人请教!~ 多服务器共享session的问题!内有详细说明 现在有一个DataTable,Table里有一条记录,关于如何修改它的值如何办? 如何在datagrid中动态增加一列? DataReader的奇怪问题,没有数据时DataReader.Read()返回true,我如何是好?
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=1509&lngWId=10
引用MSXML2.dll
using MSXML2;
string url = "xxxx";
XMLHTTP http = new XMLHTTP();
try
{
http.open("GET", url, false, null, null);
http.send(null);
int iStatus = http.status;
//如果取得的网页状态不正确, 就是不存在或没权访问
if(iStatus != 200)
return -1;
}
catch(Exception ex)
{
Console.Write(ex.ToString());
try
{
EventLog.WriteEntry("xxxxx", url + "不能访问!", EventLogEntryType.Error);
}
catch{}
return -1;
}
你老哥的方法不行呀,哪个webservice即使可以正常使用http.status的值也不是200,而是500:请求格式无法识别
403是拒绝访问
404页面不存在
我写的就是这个呀