You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Tom (JIRA)" <ax...@ws.apache.org> on 2005/08/16 09:00:54 UTC

[jira] Created: (AXIS-2178) WSDL2Java generates different code for exceptions

WSDL2Java generates different code for exceptions
-------------------------------------------------

         Key: AXIS-2178
         URL: http://issues.apache.org/jira/browse/AXIS-2178
     Project: Apache Axis
        Type: Bug
  Components: WSDL processing  
    Versions: 1.2.1    
 Environment: Java 1.4.2, Axis 1.2.1
    Reporter: Tom


With Axis 1.1 we defined the following exception:
	public class SampleException extends Exception {
	  public SampleException(String message) {
	    super(message);
	  }
	  public String getMessage() {
	    return super.getMessage();
	  }
	}

The generated complex type in the wsdl looks like this:
  ...
  <complexType name="SampleException">
  <sequence>
   <element name="message" nillable="true" type="xsd:string"/>
  </sequence>
  </complexType>
  ...

This is what WSDL2Java Axis 1.1 generates from the definition above:
	/**
	 * SampleException.java
	 *
	 * This file was auto-generated from WSDL
	 * by the Apache Axis WSDL2Java emitter.
	 */
	public class SampleException  extends org.apache.axis.AxisFault  implements java.io.Serializable {
	  private java.lang.String message;
	  public SampleException() {
	  }
	  public SampleException(
	         java.lang.String message) {
	      this.message = message;
	  }
	  public java.lang.String getMessage() {
	      return message;
	  }
	  ...
	}

And this is what WSDL2Java Axis 1.2.1 generates:
	/**
	 * SampleException.java
	 *
	 * This file was auto-generated from WSDL
	 * by the Apache Axis 1.2.1 Jun 14, 2005 (09:15:57 EDT) WSDL2Java emitter.
	 */
	public class SampleException  extends org.apache.axis.AxisFault  implements java.io.Serializable {
	  private java.lang.String message1;
	  public SampleException() {
	  }
	  public SampleException(
	         java.lang.String message1) {
	      this.message1 = message1;
	  }
	  /**
	   * Gets the message1 value for this SampleException.
	   * 
	   * @return message1
	   */
	  public java.lang.String getMessage1() {
	      return message1;
	  }
	  ...
	}     
--> A new attribute called message1 (instead of message) and a getter getMessage1() is generated 

This renamed attribute breaks existing client code because now getMessage() of an exception caught at the client side returns null instead of the message that was inserted on the server side. And because getMessage() exists (inherited from the super class of the exception) besides the new getMessage1() there is no compile time error when getMessage() is called instead of getMessage1().

I can think of 2 possible ways to fix this bug:

1) Restore the behavior of WSDL2Java of Axis 1.1

or even better

2) If there is an element 'message' of type string defined in a fault (exception) in the wsdl then instead of overwriting the 'message' attribute of the super class (as done in Axis 1.1) the 'message' element should be put into the 'message' attribute of the super class by using a suitable constructor. That way getMessage() and toString() of a caught exception would work as expected.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira