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 Sr...@ercgroup.com on 2004/04/22 11:22:41 UTC

Overriding AxisFault

Hi All,
	Is there anyway in which i can override the exception stack trace
which comes in as part of the 'detail' element in the AxisFault and give my
own customized 	messages. Any help on this would be useful.

Thanks and Regards
Sriram

Re: Overriding AxisFault

Posted by Nelson Minar <ne...@monkey.org>.
>Is there anyway in which i can override the exception stack trace
>which comes in as part of the 'detail' element in the AxisFault and
>give my own customized messages.

One option is to define a custom serializer for your Exception type.
This works but has some issues. It's also a nuisance because you have
to define a serializer for every type of Exception you care about; you
can't just define one for Exception and expect all subclasses to be
treated the same.

Another option is to make a subclass of AxisFault that does what you
want, and then make sure your own service methods only throw this
special type of Exception. I find my code is wrapped like this:
  public String myMethod(String input) {
    try {
      doSomeWork(input);
    } catch (Exception e) {
      throw new MyAxisFault(e);
    }
  }

This is also a nuisance, but it works. It also leaves me wondering if
I've missed something in Axis or if Axis needs a customization hook it
doesn't have.