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 David Green <da...@maketechnologies.com> on 2003/04/30 03:01:44 UTC

exception and SOAP fault

I've been attempting to find documentation on how to have SOAP faults created from custom exception types on the server, and re-thrown on the client.  

There appear to be several threads on this, none of which have enough information for me to produce the desired result.  If there is known documentation on this, can someone please direct me to it?  Otherwise, does anyone know how to do this?

Desired behavior:

1. Declare a Java class on the server with methods that throw the appropriate exception type (that preferably inherits from java.lang.Exception, not AxisFault)
2. Declare the exception class with appropriate get/set methods for all properties.
3. Whenever necessary, on the server throw an instance of the exception.
4. If necessary configure (using the wsdd file) serializers for the exception class.
5. If thrown, Axis on the server creates a SOAP fault with sufficient data that the exception can be re-created on the client side.
6. Generated WSDL contains accurate fault definitions.

So far I've been able to do all of the above except for 5.  The WSDL appears to be correct, however the fault contains none of the relevant data.  If the exception class inherits from AxisFault, the fault appears as follows:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:Server.generalException</faultcode>
   <faultstring>Internal server error. (ref# 10301)</faultstring>
   <detail>
    <ns1:exceptionName xmlns:ns1="http://xml.apache.org/axis/">com.maketechnologies.webservice.test.BusinessException</ns1:exceptionName>
   </detail>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>

This causes the client to properly instantiate the BusinessException, however the BusinessException contains the following information (from WSDL):

<complexType name="TestException">
  <sequence>
    <element name="message" nillable="true" type="xsd:string" /> 
  </sequence>
</complexType>
<complexType name="BusinessException">
  <complexContent>
    <extension base="impl:TestException">
      <sequence>
       <element name="errorCode" type="xsd:int" /> 
      </sequence>
    </extension>
  </complexContent>
</complexType>

As you can see, the errorCode is not transmitted over the wire.

Any help and/or pointers to documentation would be greatly appreciated.

David