Solved

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

Posted on 2007-03-23
7
304 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different Delete Messages 7 37
Help with concatenating data from one data element to another using VB.NET 3 33
Problem to error 4 43
Replace &lt; with < 14 54
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

932 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

9 Experts available now in Live!

Get 1:1 Help Now