Solved

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

Posted on 2008-06-18
2
413 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
ID: 21815890
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
ID: 31468508
Thanks,  this worked as I had hoped.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.net VBA word safemode 1 35
Convert to Hour/minute textbox and compare 3 52
Help with Syntax 9 23
Get the selected ValueMember of Combobox 5 15
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

948 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

19 Experts available now in Live!

Get 1:1 Help Now