Axis fault handling is essentialy undocumented, at least anywhere I could find. I spent the better part of the last two days experimenting so I could understand how to properly do some error handling. This seems like an important thing, and seems to generate quite a few email, so to save others some work I thought I would share my notes.
I am hoping an axis developer will review this and offer any needed corrections. PErhpas this could be incorporated into the docs somehow. I suppose I could add this to the wiki, but the docs could still use more information. I have also attached a zip files with two samples. One is a beefed up copy of the sample/faults example included in r1.1. The other is a full blown example of using service specific exceptions, with a wsdl file and everything. It parallels the original example. This may be useful and could even be added to the current examples. Rick Hansen Axis fault handling notes: - For all practical purposes a client programmer can treat Axis as if it only throws org.apache.axis.AxisFault exceptions. - Axis does not throw javax.xml.rpc.soap.SOAPFaultException. Axis never creates a SOAPFaultException itself. However, since SOAPFaultException is unchecked, one could leak through if thrown by a handler or service implementation. - The invoke methods that are likely to be called by a client programmer (the ones inherited from javax.xml.rpc.Call) return either a service specific exception or org.apache.axis.AxisFault. - A service implementation can throw any type of exception. - Axis faults thrown by a service implementation are returned to the client just as thrown. - A non AxisFault thrown by a service implementation but not configured as a service specific exception will be wrapped in an AxisFault on the client. A faultCode of Server.userException and a local stack trace will be included in the Axisfault. This is not the most useful thing that could happen as it tends to hide the source/cause of the exception. The fault string included represents the original exception. - Axis must be configured to handle service specific exceptions and recreate them on the client. - Service specific exceptions can can be configured using either parameters in the wsdd deployment file or using calls to org.apache.axis.description.OperationDesc in the service stubs and skeletons. - Service specific exceptions must subclass org.apache.axis.AxisFault. - The WSDL to Java tools will create service specific exceptions that are defined in a wsdl file and create the required configuration code in the stubs and skeletons generated.
samples.zip
Description: Binary data
