Solved

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

Posted on 2008-06-18
2
430 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with consolidating excel files using VB.net 2 35
VB.NET 2008 Publish Error 2 43
location of a form 2 32
VB.net Open video relating to control 2 29
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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