Solved

How to check the availability of a web service before calling it. C#

Posted on 2007-03-23
7
303 Views
Last Modified: 2013-12-17
Hi,

I would like to check the availability of a web service before calling it through c#. Sort of like a ping.

How would I accomplish this.
0
Comment
Question by:terrorbyte
  • 4
7 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 18779059
you could use system.net.webrequest / webresponse and check to see if the getresponse method returns null
0
 

Author Comment

by:terrorbyte
ID: 18779299
Hi p davis,
how exactly would i do that?
0
 
LVL 22

Accepted Solution

by:
p_davis earned 500 total points
ID: 18780383
WebRequest myRequest = WebRequest.Create(site);
            WebResponse myResponse = myRequest.GetResponse();

where site is the url
0
 
LVL 22

Expert Comment

by:p_davis
ID: 18781250
also instead of checking for null you would probably want to do some exception handling with a try block
0
 
LVL 22

Expert Comment

by:p_davis
ID: 18977206
did you get it figured?
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now