Solved

Using VB.Net 2005 how do I test for a web service to determine if it running?

Posted on 2008-06-18
2
403 Views
Last Modified: 2010-05-18
What is the best practice way to programmatically determine if a web service is running?  This must be done using MS VB 2005.
0
Comment
Question by:tegronakron
2 Comments
 
LVL 7

Accepted Solution

by:
Zippit earned 500 total points
Comment Utility
If you just want to check if the webservice is responding, the attached code will work.  Essentially a webservice is just a web page (URL) that accepts standardized XML in the request and responds with standardized XML.  So the attached code just checks if the passed in URL (this would be the URL where the webservice is hosted, ie http://www.mydomain.com/mywebsvc.asmx ) is resolvable and is responding.  By default it waits 5 seconds, but you can change this easily.

HTH
Private Function isSiteAccessible(ByVal url As String) As Boolean

        Dim rv As Boolean = False

        Dim req As HttpWebRequest = WebRequest.Create(url)

        Dim res As HttpWebResponse = Nothing
 

        req.Timeout = 5000      ' 5 seconds

        'req.UserAgent = "My Web Checker"
 

        Try

            res = CType(req.GetResponse(), HttpWebResponse)
 

            If res.StatusCode = 200 Then

                rv = True

            End If
 

        Catch ex As Exception
 

        End Try
 

        Return rv

    End Function

Open in new window

0
 

Author Closing Comment

by:tegronakron
Comment Utility
Thanks,  this worked as I had hoped.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

10 Experts available now in Live!

Get 1:1 Help Now