Determine if a WebService is running?

Posted on 2005-05-09
Last Modified: 2010-04-01
Hi everyone!

I have an application that should call an webservice that can reside on any computer in my network. I use the SetUrl() to set the acutal location of the Webservice but as I don´t know which URL the WebService resides on I would like to have a couple of different URL:s to choose from. Now I´m wondering if it´s possible to determine if a WebService is running without making an actual call to one of the interfaces? Something like this:

MyWebService* GetWebService()
   bool bIsRunning = false;
   while( bIsRunning == false )
        MyWebService* pService = new MyWebService();
        // Check if WebService is running????
        bool bIsRunning = pService->IsRunning();             < ----- THIS IS WHAT I NEED HELP WITH
        if( bIsRunning )
            return pService;
Question by:TYB
    LVL 16

    Expert Comment

    You can just try to see whether the webservice location is accessible (e.g. by browsing)
    LVL 86

    Expert Comment

    >>I use the SetUrl() to set the acutal location of the Webservice

    'SetUrl()' returns a HRESULT code - if it fails (i.e. because there is no service) you should receive an error code instead of 'S_OK'.

    Author Comment

    The browsing idea can´t be used... I want to do this programatically.

    But I tested the SetUrl() resultcode and it returns S_OK even if I try to set the URL to a WebService that doesn´t exists...strange!

    Any ideas?
    LVL 16

    Accepted Solution

    >The browsing idea can´t be used... I want to do this programatically.

    What about InternetOpen and InternetOpenURL from wininet?

    Author Comment

    Ok.... by browsing I thought you meant the IE or something like that.

    I´ll have a look at the InternetOpen and InternetOpenURL...tnx!

    I´ll get back to you when I have tried it out...

    Author Comment

    I´m sorry for not accepting earlier... got a lot of other work to do. Tnx for your answer solved my problem.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now