You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jay Glanville <Ja...@naturalconvergence.com> on 2005/03/17 04:01:44 UTC

Is it possible to catch a custom fault?

Hello all.

I have a custom fault class that extends AxisFault in my Axis server.
It basically holds information about validation errors (invalid
information was passed in).

   public class ValidationFault extends AxisFault { ... }

I use this fault on methods in my service where information that is
being sent to the server needs to be validated.  For example:

   public int addBean( Bean newData )
         throws ValidationFault {
      if ( /* bean contains invalid data */ ) {
         throw new ValidationFault( /* error info */ );
      }
      ...
   }


Now, on my client, I have a try / catch block that looks something like
this:

   try {
      serverBinding.addBean( badData );
      ....
   } catch ( ValidationFault validFault ) {
      System.out.println( "caught validation fault" );
   } catch ( AxisFault genFault ) {
      System.out.println( "caught validation fault" );
   }

Now, here's the interesting bit: if my server's method throws a
ValidationFault, my client catches it as an AxisFault, and NOT a
ValidationFault.  In other words, my ValidationFault is being
'dummed-down' into an AxisFault.

Is this expected behaviour?

Is it possible to throw AND catch custom faults?  If so, how?


The reason I'm subclassing AxisFault is because someone on this list
suggested that this is the way to do it
(http://marc.theaimsgroup.com/?l=axis-user&m=110727059025671&w=2).


Thanks
 
 
---
Jay Glanville