多线程中检测某个.asmx链接是否有效
我的测试code:
try
{
System.Net.WebRequest myRequest = System.Net.WebRequest.Create( "http://192.168.0.6/rootserver/DirService.asmx ");
System.Net.WebResponse myResponse = myRequest.GetResponse();
return "ok ";
}
catch(Exception ex)
{
return ex.Message.ToString();
}
//引入命名空间MSXML2
using MSXML2;
public bool getWSStatus()
{
string url = "http://192.168.105.10/hotelwebsrv/hotelwebsrv.asmx";
XMLHTTP http = new XMLHTTP();
try
{
http.open("GET", url, false, null, null);
http.send(null);
int iStatus = http.status;
//如果取得的网页状态不正确, 就是不存在或没权访问
if (iStatus == 200)
return true;
else
return false;
}
catch
{
return false;
}
}