Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I Check whether the Web Service is up

Posted on 2009-05-06
9
Medium Priority
?
2,055 Views
Last Modified: 2013-11-18
Hi, I am sending requests to a webservice which exposes methods queryCustomer(), createCustomer(), deleteCustomer(). Before sending a request
I want to make sure that the WebService is up. If the WebService is down, I would queue up the order and wait for the WebService to come up. If I don't make this check and send the order to the WebService (assuming that Service is up), the order will fail and then the upstream system (my application sit between an upstream system and a downstream system) has to sned the order again, which I don't want to happen.

Now the approach I have thought is to send a dummy query request (using queryCustomer) before sending the actual order. If the query is successful, that means the WebService is up, now I can send the actual request. If the query response is Null, it means the WebService is down, and I need to queue the request.

The problem with this approach is that every hit on the web service bears some cost to us, so I want to avoid sending dummy requests.

Is there a way I can check whether the WebService is up without actually calling a method? Can it be achieved by trying to get a reference to endpoint URL of the WebService. When I code (I am using axis 1.4 libraries and used WSDL2Java to generate the binding classes from the WSDL):

samplePort = service.getCustomerPort(url);  

will this call be successful when the Service is down? If the call fails when the Service is down, I can use this as a check without sending the query request to the WebService.

Any suggestions on this please?

Thanks

0
Comment
Question by:LeoKris
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24322587
if the webservice does not provide its own health check, you loose
you only may call the ?wsdl to check if this part of the application is reachable at all
if the WSDL file is served by the web service itself, you chances are high tht the web service is alive
0
 

Author Comment

by:LeoKris
ID: 24333202
what do you mean that I call the "?wsdl", because I am calling it from my java code and not typing the URL in explorer.

I think making a dummy call to the webservice is the only way.

Thanks anyways.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 24333512
> what do you mean that I call the "?wsdl
I meant to make a request to a proper  URL with ?wsdl query string using your java API's HttpRequest method.
0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 

Author Comment

by:LeoKris
ID: 24333625
Sounds good...let me try.. I will let you know if it works.
0
 

Author Comment

by:LeoKris
ID: 24334420
I am trying this code:

String requestUrl= "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
            
            try {
            
                  URL url = new URL(requestUrl.toString());
           
                  
                         HttpURLConnection aConnection = (HttpURLConnection) url.openConnection();
      BufferedReader buffer = new BufferedReader(new InputStreamReader(aConnection.getInputStream()));

                       String line = "";
                       while ((line = buffer.readLine()) != null)
                                                   {
                           System.out.println(line);
                       }

But when I run the code, I get this exception:

java.net.UnknownHostException: www.w3schools.com

I can access this WSDL by typing the url in my explorer. Any clue on this?

Thanks
0
 

Author Closing Comment

by:LeoKris
ID: 31578352
thanks for help
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24348227
> java.net.UnknownHostException: www.w3schools.com
try to set the Host: header to that www.w3schools.com
0
 

Expert Comment

by:deep_scorpion
ID: 35228670
Hi Leokris,

I am developing a similer tool where I need to check if the webservice is up or down.
can you share your code for the same?
0
 

Author Comment

by:LeoKris
ID: 35249901
Hi deep,
   my code is specific to the webservice I am consuming. I didn't go with the "fetch-the-wsdl" technique. I actually invoked the service passing dummy parameter (customer id for a non existing customer), which returns an error code as "101- Customer Not Found". This confirms that the WebService is Up.

Thanks

Leo
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

715 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