File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Differentiate server down and no data found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Differentiate server down and no data found" Watch "Differentiate server down and no data found" New topic

Differentiate server down and no data found

Sam Venkata
Ranch Hand

Joined: Mar 06, 2006
Posts: 68

I would like to know if java.rmi.ServerException would be thrown if the server hosting the web services is down.
Also is there a way I could differentiate if the server is down or if there is no data returned. I am using wsdl2java axis tool to generate java classes. This is what I do in my java class.

If I check for (t instanceof java.rmi.ServerException) would it be true if the server is down? Also can I modify the end point URL to an invalid url (like say change the valid port number to an invalid one ) and assume that the server is down
Please help me with this.

Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
Axis will in most cases of trouble throw an org.apache.axis.AxisFault which subclasses java.rmi.RemoteException

The AxisFault code, fault string, actor, and details identify the underlying cause.

For example:
Port isn't being listened to on the server:

Host does not exist:

With Throwable getCause() you should be able to access the underlying and respectively.

You can change the URL used by the client by specifying an alternate URL when you acquire the port from the locator.
If you simply change the port the connection will be refused as the server is still up and running.

The "no data" scenario depends on the implementation of the web service. If "no data" is a possible result under normal conditions then it is likely the service will simply reply with an empty response message which could result in an empty response object or a null reference depending on the circumstances (Null Array vs. Empty Array). If "no data" is an "exceptional" occurrence the service has the option of issuing a SOAP fault which would be listed in the WSDL - exceptions based on SOAP faults subclass java.lang.Exception (Exception handling in JAX-RPC).

Sam Venkata
Ranch Hand

Joined: Mar 06, 2006
Posts: 68
Hi Reynders,

Thanks for your explanation, I was able to understand the concept, but I have a small doubt, as per my understanding, if the server itself is down we would get but if the app on the server is down then we would get that correct? Please correct me if I am wrong.

Samanth Marisetty.
[ March 10, 2008: Message edited by: Samanth Marisetty ]
I agree. Here's the link:
subject: Differentiate server down and no data found
It's not a secret anymore!