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 "Amila Chinthaka Suriarachchi (JIRA)" <ji...@apache.org> on 2007/11/06 07:54:51 UTC

[jira] Resolved: (AXIS2-3262) WSDL2Java generates incorrect Exception stubs

     [ https://issues.apache.org/jira/browse/AXIS2-3262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Amila Chinthaka Suriarachchi resolved AXIS2-3262.
-------------------------------------------------

    Resolution: Fixed

first of all you have to understand that the wsdl2java generates the code using the given wsdl. No matter how you generate it.
When generating the exceptions here is the convention. 
For each fault element declared in the Porttype/operation it adds a java.lang.Exception for method signature. and these exceptions contains a variable to keep the inside element details. 
when considering this convention I think what wsdl2java generates is correct.

why you want to throw a remote exception from a skelton mehtod? I think this is where you have made things wrong. From the skelton you are supposed to throw only the Bussiness logic exceptions. (here Remote exception has also though as a bussiness logic exception.)

> 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
>            Assignee: Amila Chinthaka Suriarachchi
>            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>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
> WSDL, generated by ?wsdl request, is:
> ------------------------------------------------------------------------ wsdl
> <?xml version="1.0" encoding="UTF-8"?>
> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns0="http://axis.test/xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns1="http://axis.test" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://axis.test">
>     <wsdl:documentation>soapservice</wsdl:documentation>
>     <wsdl:types>
>         <xs:schema xmlns:ax21="http://axis.test/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://axis.test/xsd">
>     <xs:complexType name="RemoteException">
>         <xs:complexContent>
>             <xs:extension base="ns1:Exception">
>                 <xs:sequence/>
>             </xs:extension>
>         </xs:complexContent>
>     </xs:complexType>
> </xs:schema>
>         <xs:schema xmlns:ns="http://axis.test" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://axis.test">
>     <xs:complexType name="Exception">
>         <xs:sequence>
>             <xs:element minOccurs="0" name="Exception" nillable="true" type="xs:anyType"/>
>         </xs:sequence>
>     </xs:complexType>
>     <xs:element name="RemoteException">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element minOccurs="0" name="RemoteException" nillable="true" type="ns0:RemoteException"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
> </xs:schema>
>     </wsdl:types>
>     <wsdl:message name="testRequest"/>
>     <wsdl:message name="testResponse"/>
>     <wsdl:message name="RemoteException">
>         <wsdl:part name="parameters" element="ns1:RemoteException"/>
>     </wsdl:message>
>     <wsdl:portType name="soapservicePortType">
>         <wsdl:operation name="test">
>             <wsdl:input message="ns1:testRequest" wsaw:Action="urn:test"/>
>             <wsdl:output message="ns1:testResponse" wsaw:Action="urn:testResponse"/>
>             <wsdl:fault message="ns1:RemoteException" name="RemoteException" wsaw:Action="urn:testRemoteException"/>
>         </wsdl:operation>
>     </wsdl:portType>
>     <wsdl:binding name="soapserviceSOAP11Binding" type="ns1:soapservicePortType">
>         <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
>         <wsdl:operation name="test">
>             <soap:operation soapAction="urn:test" style="document"/>
>             <wsdl:input>
>                 <soap:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap:body use="literal"/>
>             </wsdl:output>
>             <wsdl:fault name="RemoteException">
>                 <soap:fault use="literal" name="RemoteException"/>
>             </wsdl:fault>
>         </wsdl:operation>
>     </wsdl:binding>
>     <wsdl:binding name="soapserviceSOAP12Binding" type="ns1:soapservicePortType">
>         <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
>         <wsdl:operation name="test">
>             <soap12:operation soapAction="urn:test" style="document"/>
>             <wsdl:input>
>                 <soap12:body use="literal"/>
>             </wsdl:input>
>             <wsdl:output>
>                 <soap12:body use="literal"/>
>             </wsdl:output>
>             <wsdl:fault name="RemoteException">
>                 <soap12:fault use="literal" name="RemoteException"/>
>             </wsdl:fault>
>         </wsdl:operation>
>     </wsdl:binding>
>     <wsdl:binding name="soapserviceHttpBinding" type="ns1:soapservicePortType">
>         <http:binding verb="POST"/>
>         <wsdl:operation name="test">
>             <http:operation location="soapservice/test"/>
>             <wsdl:input>
>                 <mime:content type="text/xml" part="test"/>
>             </wsdl:input>
>         </wsdl:operation>
>     </wsdl:binding>
>     <wsdl:service name="soapservice">
>         <wsdl:port name="soapserviceSOAP11port_http" binding="ns1:soapserviceSOAP11Binding">
>             <soap:address location="http://localhost:8081/axis/axis2/soapservice"/>
>         </wsdl:port>
>         <wsdl:port name="soapserviceSOAP12port_http" binding="ns1:soapserviceSOAP12Binding">
>             <soap12:address location="http://localhost:8081/axis/axis2/soapservice"/>
>         </wsdl:port>
>         <wsdl:port name="soapserviceHttpport" binding="ns1:soapserviceHttpBinding">
>             <http:address location="http://localhost:8081/axis/axis2/soapservice"/>
>         </wsdl:port>
>     </wsdl:service>
> </wsdl:definitions>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org