Hi,
How can I validate web service URL. I have tried with
pinging the URL, is it the right way to do so and will it work for all types of
web services. I have tried this…
System.Net.NetworkInformation.Ping
lObjPing = new System.Net.NetworkInformation.Ping();
System.Net.NetworkInformation.PingReply
lObjPingReply = null;
lObjPingReply = lObjPing.Send(URL);
Please help out.
Thanks
Sreenath
Sreenath GPosted Nov 25, 2011, 7:39 AM
string Http_URL = HttpUtility.UrlDecode(URL);
HttpWebRequest lObjReq = (HttpWebRequest)HttpWebRequest.Create(Http_URL);
lObjReq.Timeout = 36000;
lObjReq.UseDefaultCredentials = true;
if (lObjReq.GetResponse().ContentLength
> 0)
{
Output_Err = "";
lStrLog = URL
+ " is a Valid URL.";
return true;
}
else
{
lStrLog = Output_Err = "Invalid URL or Web Service.";
return false;
}