...
Wiki Markup |
---|
{snippet:id=payload|lang=java|url=activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java} |
How to throw the SOAP Fault from Camel
If you are using the camel-cxf endpoint to consume the SOAP request, you may need to throw the SOAP Fault from the camel context.
Basically, you can use the throwFault DSL to do that, it works for POJO, PAYLOAD and MESSAGE data format.
You can define the soap fault like this
Wiki Markup |
---|
{snippet:id=FaultDefine|lang=java|url=activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java} |
Then throw it as you like
Wiki Markup |
---|
{snippet:id=ThrowFault|lang=java|url=activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustomizedExceptionTest.java} |
If your cxf endpoint working in the MESSAGE data format, you could set the the SOAP Fault message into the message body and set the response code in the message header.
Wiki Markup |
---|
{snippet:id=MessageStreamFault|lang=java|url=activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMessageStreamExceptionTest.java} |
NOTE the response code setting only works in Camel's version >= 1.5.1
How to propagate camel-cxf endpoint's request and response context
...