This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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).
Joined: Mar 06, 2006
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.