axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22204] - WS client throws wrong exception types
Date Tue, 12 Aug 2003 07:45:13 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22204>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22204

WS client throws wrong exception types





------- Additional Comments From joern.gebhardt@ptv.de  2003-08-12 07:45 -------
Hi Tom,

here is a small test case for a WS (MyTestWS) that throws two different 
exceptions FirstTestException and SecondTestException depending on the input 
parameter:

FirstTestException:

  package com.mytest.exception;
  public class FirstTestException extends Exception {
      public FirstTestException() {
          super();
      }
  }

SecondTestException:

  package com.mytest.exception;
  public class SecondTestException extends Exception {
      public SecondTestException() {
          super();
      }
  }

MyTestWS:

  package com.mytest;
  import java.rmi.RemoteException;
  public class MyTestWS implements java.io.Serializable {
      /**
       * Throws either FirstTestException or SecondTestException
       */
      public void throwTestException(boolean first)
              throws com.mytest.exception.FirstTestException,
                     com.mytest.exception.SecondTestException,
                     RemoteException {
          if (first) {
              throw new com.mytest.exception.FirstTestException();
          } else {
              throw new com.mytest.exception.SecondTestException();
          }
      }
  }

MyTest.wsdl (using Java2WSDL):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://mytest.com" 
xmlns="http://schemas.xmlsoap.org/wsdl/" 
xmlns:apachesoap="http://xml.apache.org/xml-soap" 
xmlns:impl="http://mytest.com" xmlns:intf="http://mytest.com" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:tns1="http://exception.mytest.com" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <wsdl:types>
  <schema targetNamespace="http://exception.mytest.com" 
xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
   <complexType name="BaseException">
    <sequence/>
   </complexType>
   <complexType name="FirstTestException">
    <complexContent>
     <extension base="tns1:BaseException">
      <sequence/>
     </extension>
    </complexContent>
   </complexType>
   <complexType name="SecondTestException">
    <sequence/>
   </complexType>
  </schema>
 </wsdl:types>
   <wsdl:message name="throwTestExceptionRequest">
      <wsdl:part name="in0" type="xsd:boolean"/>
   </wsdl:message>
   <wsdl:message name="throwTestExceptionResponse">
   </wsdl:message>
   <wsdl:message name="FirstTestException">
      <wsdl:part name="fault" type="tns1:FirstTestException"/>
   </wsdl:message>
   <wsdl:message name="SecondTestException">
      <wsdl:part name="fault" type="tns1:SecondTestException"/>
   </wsdl:message>
   <wsdl:portType name="MyTestWS">
      <wsdl:operation name="throwTestException" parameterOrder="in0">
         <wsdl:input message="impl:throwTestExceptionRequest" 
name="throwTestExceptionRequest"/>
         <wsdl:output message="impl:throwTestExceptionResponse" 
name="throwTestExceptionResponse"/>
         <wsdl:fault message="impl:SecondTestException" 
name="SecondTestException"/>
         <wsdl:fault message="impl:FirstTestException" 
name="FirstTestException"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="mytestSoapBinding" type="impl:MyTestWS">
      <wsdlsoap:binding style="rpc" 
transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="throwTestException">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="throwTestExceptionRequest">
            <wsdlsoap:body 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="http://mytest.com" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="throwTestExceptionResponse">
            <wsdlsoap:body 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="http://mytest.com" use="encoded"/>
         </wsdl:output>
         <wsdl:fault name="SecondTestException">
            <wsdlsoap:fault 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="http://mytest.com" use="encoded"/>
         </wsdl:fault>
         <wsdl:fault name="FirstTestException">
            <wsdlsoap:fault 
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
namespace="http://mytest.com" use="encoded"/>
         </wsdl:fault>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="MyTestWSService">
      <wsdl:port binding="impl:mytestSoapBinding" name="mytest">
         <wsdlsoap:address location="http://xml.com/mytest"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>


A test case with the following code should work correctly in the fixed version:

void test() {
  MyTestWS ws = null;
  // do the binding stuff
  [..]
  try {
    ws.throwTestException(true);
  catch (FirstTestException fte) {
    // we should end up here
  } catch (Exception ex) {
    fail("Expected FirstTestException.");
  }
  
  try {
    ws.throwTestException(false);
  catch (SecondTestException fte) {
    // we should end up here
  } catch (Exception ex) {
    fail("Expected SecondTestException.");
  }
}


Thanks for fixing the bug,
Joern

Mime
View raw message