XFireHome M5M6-SNAPSHOTDevelopersDeveloper Space |
Exceptions in ServicesAny non-runtime exception that is thrown by a service will eventually be caught by XFire and turned into a Fault. The fault is created by the static method XFireFault.createFault(Exception e). If a fault occurrs, all the handlers that been executed will have their handleFault() method executed in the order reverse of execution. FaultHandlers are responsible for turning an XFireFault into a SOAP Fault written on the wire. If you wish to do custom processing of how Faults are handled you must write your own FaultHandler and set it as the FaultHandler on your service: Service myService = ...;
myService.setFaultHandler(new CustomFaultHandler);
There is also a FaultPipeline. If a fault occurs and you need to do something special during such an occurrence, but still want to let XFire write the fault message you can add a FaultHandler to the FaultPipeline: Service myService = ...; FaultPipeline pipe = new FaultPipeline(); pipe.addHandler(new MyFaultHandler()); myService.setFaultPipeline(pipe); Note that while FaultHandlers are used in both the Service.getFaultHandler() and the FaultPipeline, only the FaultHandler from Service.getFaultHandler() can write out the fault message. |