You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Thomas Fischer <Fi...@seitenbau.net> on 2003/10/20 19:14:06 UTC

Call.setReturnType() prevents "proper" Exception Mapping




Hi,

As I am quite new using Axis, I am not sure whether this is a bug or
expected behaviour. I did not find anything about the behavior in bugzilla.

In the server, a method throws a Custom Exception which extends
java.rmi.RemoteException.
In the client, I am calling this method. The Exception thrown by
Call.invoke() has the same class as the original exception if the method
Call.setReturnType() is NOT invoked before making the call. If the method
Call.setReturnType() is invoked, the Client throws an AxisFault instead.
In my Application, I would like an Exception of the original class to be
rethrown whether or not Call.setReturnType() is invoked.

This behaviour is can be reproduced in Axis 1.1 as well as in today's(Oct
20, 2003) snapshot from the CVS.

Any comments on this would be greatly appreciated,

    Cheers,

         Thomas

P.S code used for testing:

Client:

    try {
      String endpoint =
                "http://localhost:8999/axistest/services/MyService";
      org.apache.axis.client.Service service
          = new org.apache.axis.client.Service();
      String uri = "urn:Axistest";
      javax.xml.namespace.QName qn
          = new javax.xml.namespace.QName( uri, "AxisTestException" );
      org.apache.axis.client.Call call
          = (org.apache.axis.client.Call) service.createCall();
      call.registerTypeMapping(AxisTestException.class, qn,
                    new
org.apache.axis.encoding.ser.BeanSerializerFactory(AxisTestException.class,
qn),
                    new
org.apache.axis.encoding.ser.BeanDeserializerFactory(AxisTestException.class,
 qn));

      call.setTargetEndpointAddress( new java.net.URL(endpoint) );
      call.setOperationName(new javax.xml.namespace.QName(uri,
"throwException"));
      // if any of these two lines is uncommented, the following call
throws an
      // AxisFault instead of an AxisTestException
      //call.setReturnType( org.apache.axis.encoding.XMLType.XSD_STRING );
      //call.setReturnType( null );
      String ret = (String) call.invoke( new Object[] {} );
    }
    catch (Exception e) {
      System.err.println("Exception Class : " + e.getClass().getName());
    }

Server:

  public String throwException() throws AxisTestException {
    throw new AxisTestException();
  }

Exception:

public class AxisTestException extends java.rmi.RemoteException {
  public AxisTestException() {}
}

snippet from server-config.wsdd

 <service name="MyService" provider="java:RPC">
  <parameter name="allowedMethods" value="*"/>
  <parameter name="className" value="axistest.Axistest"/>
  <beanMapping languageSpecificType="java:axistest.AxisTestException"
qname="ns1:AxisTestException" xmlns:ns1="urn:Axistest"/>
 </service>