WSDL2Java generates incorrect Exception stubs
---------------------------------------------
Key: AXIS2-3262
URL: https://issues.apache.org/jira/browse/AXIS2-3262
Project: Axis 2.0 (Axis2)
Issue Type: Bug
Components: wsdl
Affects Versions: 1.3
Reporter: Oleg Efimov
Priority: Critical
I'm going to show simple example of the problem.
First, I create a test service:
--------------------------------------------------------------
test.axis.SoapService
package test.axis;
public class SoapService {
public void test() throws RemoteException {
}
}
---------------------------------------------------------------
test.axis.RemoteException
package test.axis;
public class RemoteException extends Exception{
public RemoteException() {
}
public RemoteException(Throwable cause) {
super(cause);
}
public RemoteException(String message) {
super(message);
}
public RemoteException(String message, Throwable cause) {
super(message, cause);
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I deploy it on tomcat5.5 on context /axis, web.xml is:
---------------------------------------------------------------- web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>Axis2Servlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Axis2Servlet</servlet-name>
<url-pattern>/axis2/*</url-pattern>
</servlet-mapping>
</web-app>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Service description:
----------------------------------------------------------------- services.xml
<service name="soapservice" scope="application">
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass">test.axis.SoapService</parameter>
</service>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
I use default axis2.xml with only one change:
------------------------------------------------------------------------ change
in axis2.xml
<parameter name="servicePath">axis2</parameter>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Then I use wsdl2java task to create client stubs:
-------------------------------------------------------------------------
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="testaxis2" basedir=".">
<path id="build.classpath">
<fileset dir="C:/axis2lib" includes="*.jar"/>
</path>
<macrodef name="wsdl2java">
<attribute name="url"/>
<attribute name="targetdir"/>
<attribute name="package"/>
<sequential>
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="yes"
classpathref="build.classpath">
<arg value="-or"/>
<arg value="-u"/>
<arg value="-uw"/>
<arg value="-sp"/>
<arg value="-p"/>
<arg value="@{package}"/>
<arg value="-o"/>
<arg value="@{targetdir}"/>
<arg value="-uri"/>
<arg value="@{url}"/>
</java>
</sequential>
</macrodef>
<target name="test-wsdl">
<wsdl2java targetdir="c:/testaxis"
url="http://localhost:8081/axis/axis2/soapservice?wsdl"
package="test.axis.stub"/>
</target>
</project>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
This task generates the following file tree inside testaxis/src/test/axis
folder:
----------------------------------------------------------
/stub
RemoteExceptionException0.java
Soapservice.java
SoapserviceCallbackHandler.java
SoapserviceStub.java
/xsd
ExtensionMapper.java
RemoteException.java
Exception.java
RemoteException0.java
------------------------------------------------------------------------------------------------------------------------------------------------------------------
So, we've got plenty of exception classes here. To briefly describe their
relations in UML-like style, I can say:
test.axis.stub.RemoteExceptionException0 HAS test.axis.RemoteException0 IS
java.lang.Exception
test.axis.RemoteException0 HAS test.axis.xsd.RemoteException
test.axis.xsd.RemoteException IS test.axis.Exception
Stub method test() is reported to throw
test.axis.stub.RemoteExceptionException0, which is simply java.lang.Exception,
not an AxisFault, so really in case of RemoteException on server I'll get just
AxisFault with message preserved, not any specific RemoteException I've wanted.
I believe, only one exception stub should be generated, called RemoteException,
and it should subclass AxisFault.
PS Damn, I really hope someone will read it :)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]