Hi,
CXF WebFaultOutInterceptor did almost same thing as you do (checking the
annotation and write the detail info)
Basically you just need to throw the exception out in your processor.
I'm just wondering why it doesn't work for you case.
Willem
S. Ali Tokmen wrote:
Hello
On 05/08/2010 13:26, Willem Jiang wrote:
If you just throw an normal exception, you may need to set the Fault
detail yourself.
As CxfConsumer doesn't know how to deal with it.
Well... It would have with the code I have sent before.
Basically, with that modification, when the CxfConsumer receives an
exception, it looks it that exception has a @WebFault annotation. In
that case, after having created the Fault object, it retrieves the
details of the @WebFault (namespace and name) to put them as the Fault's
details.
Sinppet:
Throwable cause = exchange.getProperty(
Exchange.EXCEPTION_CAUGHT, Throwable.class);
Fault fault = new Fault(cause);
if (cause.getMessage() != null) {
fault.setMessage(cause.getMessage());
} else {
// The exception has no message (for example, NPEs don't)
// Set Fault message to exception type
fault.setMessage(cause.getClass().getSimpleName());
}
WebFault faultAnnotation =
cause.getClass().getAnnotation(WebFault.class);
if (faultAnnotation != null) {
// This exception is a WebFault. Add details.
Element detail = fault.getOrCreateDetail();
Element faultDetails = detail.getOwnerDocument().createElementNS(
faultAnnotation.targetNamespace(), faultAnnotation.name());
detail.appendChild(faultDetails);
}
exchange.getOut().setFault(true);
exchange.getOut().setBody(fault);
But anyways, this is only a minor evolution.
Cheers