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.
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 java.net.ConnectException and java.net.UnknownHostException 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).
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 java.net.UnknownHostException but if the app on the server is down then we would get java.net.ConnectException.Is that correct? Please correct me if I am wrong.