Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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