Hi all

I want to throw an application exception that behaves like a normal
java.lang.Exception, i.e. where getMessage() gets the error message
and toString() returns a properly formatted string representation of
the exception. Therefore I defined an exception that extends
java.lang.Exception, generated a wsdl file and then from the wsdl file
the stubs and skeletons.

I tried the following 3 ways without success. I know that at least the
3rd way used to work with Axis 1.1.

Questions:
- Am I making a mistake?
- Is there a bug in WSDL2Java of Axis 1.2.1 or why is the attribute
'message' renamed to 'message1'?
- Are there any workarounds to avoid the renaming of the attribute 'message'?

Thanks


1) I defined an application exception that is thrown by a method
defined in the service interface

  public class SampleException extends Exception {
    public SampleException(String message) {
      super(message);
    }
  }

That is what Java2WSDL put in the wsdl file:

  <wsdl:types>
    ...
    <complexType name="SampleException">
    <sequence/>
    </complexType>
    ...
  </wsdl:types>
  
--> No message element  

The excpetion generated from the wsdl file looks like that:

  public class SampleException  extends org.apache.axis.AxisFault 
implements java.io.Serializable {
  
    public SampleException() {
    }

    ...
  }
  
--> No message attribute
   

2) So I implemented a getter method for the message attribute:

  public class SampleException2 extends Exception {
    
    public SampleException2(String message) {
      super(message);
    }
    
    public String getMessage() {
      return super.getMessage();
    }
  
  }

That is what Java2WSDL put in the wsdl file:

  <wsdl:types>
    ...
   <complexType name="SampleException2">
    <sequence>
     <element name="message" nillable="true" type="soapenc:string"/>
    </sequence>
   </complexType>
    ...
  </wsdl:types>
  
--> There is a message element as expected

The excpetion generated from the wsdl file looks like that:

  public class SampleException2  extends org.apache.axis.AxisFault 
implements java.io.Serializable {
    private java.lang.String message1;
    
    public SampleException2() {
    }
    
    public SampleException2(
           java.lang.String message1) {
        this.message1 = message1;
    }
    
    ...
  }

--> The message attribute was renamed to message1


3) Finally I tried to overwrite the message attribute in my
application exception (this worked well with Axis 1.1):

  public class SampleException3 extends Exception {
    
    private String message;
    
    public SampleException3(String message) {
      this.message = message;
    }
    
    public String getMessage() {
      return this.message;
    }
  
  }

That is what Java2WSDL put in the wsdl file:

  <wsdl:types>
    ...
    <complexType name="SampleException3">
    <sequence>
     <element name="message" nillable="true" type="soapenc:string"/>
    </sequence>
    </complexType>
    ...
  </wsdl:types>

--> There is a message element as expected

The excpetion generated from the wsdl file looks like that:
  
  public class SampleException3  extends org.apache.axis.AxisFault 
implements java.io.Serializable {
    private java.lang.String message1;

    public SampleException3() {
    }

    public SampleException3(
           java.lang.String message1) {
        this.message1 = message1;
    }

    ...
  }

--> The message attribute was renamed to message1

Reply via email to