Platinum Partner

Extention method for validation web service address

Our projects consist of many web service and it’s so important that have usedapplication-to -application communications and these url address of web services must be valid.Because be valid or be running web service doesn’t  affect single app , affect all apps.

i am coded a extention method for validation web service address , in below code snippet you can see it

public static class WebServiceExtention
{
    public static bool isValidWebServiceUrl(this string url)
    {
        bool rv = true;
        if (String.IsNullOrEmpty(url))
            rv = false;
 
        string Http_URL = HttpUtility.UrlDecode(url);
 
        HttpWebRequest ObjReq = (HttpWebRequest)HttpWebRequest.Create(Http_URL);
        ObjReq.Timeout = 36000;
        ObjReq.UseDefaultCredentials = true;
 
        try
        {
            if (ObjReq.GetResponse().ContentLength < 0)
                rv = false;
        }
        catch (Exception)
        {
            rv = false;
        }
        return rv;
    }
}
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}