axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ROSSILLE Samuel" <>
Subject RE: AxisFault and CustomException
Date Thu, 04 Oct 2007 13:50:34 GMT


I'm not yet Axis2 guru, but i think i understand your problem :-)


When the java method of your service throws a method, axis translates the java exception into
a soap fault. Soap fault is less structured than a java exception. It has only a soap:code
and a soap:reason. Both are text elements. By default, axis sets this text to the value of
the stack trace of the java exception (look at comments at the beginning of axis2.xml).


Then, when your client catches the soap fault, it raises an AxisFault, which is a java exception,
but you have lost the structure, because of the fact that there is no equivalent in soap to
the very structured java exception.


getDetail() just gives you soap element  which contains the code and the reason.


For myself, I would not use a soap fault, but encapsulate the result type of my method in
a wrapper which contains an error code (one of the codes means that result ok). If the method
fails, the error code gives you the exception and the wrapper object would be null:


package axis2test;
public class MyService {
    public MyService() {
    public MyDataType addOneToPositiveValue(int value) throws CustomException {

        MyDataType result = new MyDataType();

        if(value < 1) {

            return 0;
        else {


             return(value + 1);

package axis2test;
public class MyDataType {
    private int data;

    private int errorCode;


    public getters, setters,...




Samuel Rossilel


De : Pär Malmqvist [] 
Envoyé : jeudi 4 octobre 2007 15:20
À :
Objet : AxisFault and CustomException


I have created a simple Axis2 service called MyService, se code below. It has one method:
addOneToPositiveValue. If it is called with a negative value it throws a CustomException.
I have created a MyService.aar and deployed it on Axis2 1.3 and Tomcat 5.5.23
Then I created a simple client with wsdl2java and xmlbeans style.
Its really hard to get the CustomException in an easy way at the client side.
The AxisFault.getDetail() displays the name of the exception deep down in some kind of stacktrace.
Thats all.
Can you Axis2 gurus have a look at it please?
If I haven't missed anything I think something has to be done to make this easier.

package axis2test;
public class MyService {
    public MyService() {
    public int addOneToPositiveValue(int value) throws CustomException {
        if(value < 1) {
            throw(new CustomException());
        return(value + 1);
package axis2test;
public class CustomException extends Exception {   
    private static final long serialVersionUID = 999999999;
    public CustomException() {
    public String toString() {
        return(super.toString() + ' axis2test.CustomException');
<service name='MyService' scope='application'>
        This is a webservice for MyService
        <messageReceiver mep=''
    <parameter name='ServiceClass' locked='false'>axis2test.MyService</parameter>


Get news, entertainment and everything you care about at Check it out! <>

View raw message