Handling web service faults
Sometimes errors happen during the processing of requests, and you want to return that error as a SOAP Fault message. This recipe will show you how to catch exceptions within your web service routes, and return an appropriate SOAP Fault.
Getting ready
This recipe assumes that you have a project with JAX-WS artifacts created as described in the Generating the service stubs from a WSDL recipe. To use the generated API, you need to include a dependency to that project in your build:
<dependency> <groupId>org.camelcookbook.examples</groupId> <artifactId>ws-payments-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
This recipe's example is based on paymentService.wsdl
, whose transferFunds
operation can return a fault of type FaultMessage
:
<wsdl:portType name="Payment"> <wsdl:operation name="transferFunds"> <wsdl:input message="tns:TransferRequest"...