How do I Check whether the Web Service is up
Posted on 2009-05-06
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?