I've created a webservice and used Axis2 to generate all "skeleton" java classes. Then I of course implemented the service operations myself.
In the implementation, I can throw a MyException which is then caught by the generated classes and converted to an AxisFault object, which in turn is converted to a soap fault (deep down in the Axis framework) with the attribute <faultcode>soapenv:Server</faultcode>
My problem is I would like a custom dynamic faultcode, not "soapenv:Server".
I tried to manually create an AxisFault object and throw this, but AxisFault is a RemoteException, and the generated interface which my implementation must implement, does not allow to throw RemoteException.
Is it possible to get some kind of hook or filter on the output, so that I can change the faultcode? Or any other way to control the faultcode?
Thanks in advance
Ulrik
Best Answer
The SOAP specification describes how custom fault information appears under the detail tag. The faultcode is a fixed set of value dealing with where in the SOAP processing the error was thrown.
The following is an example of throwing a custom fault message
WSDL
Declare the faults in your WSDL so that the associated classes are generated:
Service code
The following code demonstrates how the custom fault messages are thrown:
TESTING
The following SOAP message
Generates the following SOAP fault response