users@jax-rpc.java.net

exception handling

From: Ian Jones <ijones_at_piper-group.com>
Date: Tue, 10 May 2005 15:16:27 +0100

All,
 
I'm attempting to throw a service-specific exception in my JAX-RPC web
service. This exception is defined, simply, as follows:
 
public class InvalidPasswordException extends Exception {
 
    public InvalidPasswordException() {
    }
 
}
 
and is thrown in the interface of my web service here:
 
String login(String password) throws RemoteException,
                                            InvalidPasswordException;
 
I then use wscompile to generate the WSDL, server ties and client stubs.
However the client stub generated for the exception is called
InvalidPasswordException_Exception and this is thrown by the login
method's client stub. Is this what should happen?
 
In my client I attempt to catch this InvalidPasswordException_Exception
exception as follows:
 
   try {
            client.login("random");
            fail("Password was not invalid");
         } catch (InvalidPasswordException_Exception e) {
             return;
         } catch (ServerException e) {
             fail(e.getMessage());
         } catch (Exception e) {
             e.printStackTrace();
             fail("failed due to exception " + e.getMessage());
         }
 
In this case the server correctly attempts to throw a new
InvalidPasswordException, but the client catches a ServerException which
mentions the InvalidPasswordException within it's message. Is this also
correct? Shouldn't I just be able to catch an InvalidPasswordException
as specified by the service's interface?
 
Many thanks for any help,
 
Ian Jones
Senior Analyst Developer
Piper Group plc
Email: ijones_at_piper-group.com
Tel: + 44 (0) 1454 284900
Fax: + 44 (0) 1454 284950
www.piper-group.com <http://www.piper-group.com/>
 
Information contained in this e-mail is intended for the use of the
addressee only, and is confidential and may be the subject of legal
professional privilege. Any dissemination, distribution, copying or use
of this communication without permission of the addressee is strictly
prohibited. The views expressed in this communication may not
necessarily be the views held by Piper Group plc.