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 Bob Cotton <bc...@synxis.com> on 2002/03/26 01:10:25 UTC

User Exception Handling in Axis

I'm using Axis to put a web service in front of a stateless session
EJB. This EJB throws user exceptions as part of it's interface.

One of these exceptions encodes an integer fault code. Let's call
this exception com.synxis.srms.exception.SrmsException.

To consume this web service from a java client, I use the following
steps:

        1. Java2WSDL on the EJB
        2. WSDL2Java on the generated WSDL
        3. Java client uses generated client stubs 

The generated client code includes its own version of SrmsException
that extends AxisFault. It also carries the integer fault code.

All the client generated interfaces and code all refer to this new
exception, com.synxis.srms.webservices.client.va.SrmsException.

BUT, when the EJB throws this exception, the client is never handed
the generated client-side exception, but instead an instance of the
server side exception.

ok, some details:

Server-side exception is:
        com.synxis.srms.exception.SrmsException.

The WSDL has this to say:
...
   <wsdl:message name="SrmsException">
      <wsdl:part name="_code" type="xsd:int"/>
   </wsdl:message>

   <wsdl:operation name="getHotelsForUser" parameterOrder="userName">
         <wsdl:input message="intf:getHotelsForUserRequest"/>
         <wsdl:output message="intf:getHotelsForUserResponse"/>
         <wsdl:fault message="intf:SrmsException" name="SrmsException"/>
   </wsdl:operation>
...

Client-side generated exception is:
        com.synxis.srms.webservices.client.va.SrmsException

/**
 * SrmsException.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis Wsdl2java emitter.
 */

package com.synxis.srms.webservices.client.va;

public class SrmsException extends org.apache.axis.AxisFault {
    public int _code;
    public int get_code() {
        return this._code;
    }

    public SrmsException() {
    }

      public SrmsException(int _code) {
        this._code = _code;
    }
}


Tcpmon has this on the wire:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <SOAP-ENV:Fault>
   <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException</faultcode>
   <faultstring>com.synxis.srms.exception.SrmsException</faultstring>
   <detail>
    <ns2:stackTrace xmlns:ns2="http://xml.apache.org/axis/">com.synxis.srms.exception.SrmsException
	at com.synxis.srms.ejbs.va.VaServiceBean.getHotelsForUser(VaServiceBean.java:51)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.apache.axis.providers.java.RPCProvider.invokeMethod(Unknown Source)
	at org.apache.axis.providers.java.RPCProvider.processMessage(Unknown Source)
	at org.apache.axis.providers.java.JavaProvider.invoke(Unknown Source)
	at org.apache.axis.strategies.InvocationStrategy.visit(Unknown Source)
	at org.apache.axis.SimpleChain.doVisiting(Unknown Source)
	at org.apache.axis.SimpleChain.invoke(Unknown Source)
	at org.apache.axis.server.AxisServer.invoke(Unknown Source)
	at org.apache.axis.transport.http.AxisServlet.doPost(Unknown Source)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java)
	at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
	at org.apache.tomcat.core.Handler.invoke(Unknown Source)
	at org.apache.tomcat.core.Handler.service(Unknown Source)
	at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
	at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
	at org.apache.tomcat.core.ContextManager.service(Unknown Source)
	at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:484)
     </ns2:stackTrace>
   </detail>
  </SOAP-ENV:Fault>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


** When the client invokes the service, and an exception is thrown, it
   is handed back an instance of the server-side exception,
   com.synxis.srms.exception.SrmsException

Any ideas?

- Bob

-- 
SynXis Corporation      | bob@synxis.com    | Obstacles are those frightful 
1610 Wynkoop, Suite 400 | Ph: (303)595-2511 | things you see when you take your
Denver, CO  80202       | Fax:(303)534-4257 | eyes off your goal.  -Henry Ford