Daniel Kulp a écrit :
On Saturday 01 November 2008 6:42:24 am Pascal Ognibene wrote:
Hi,
I've written a web service implementation (wsdl first) using CXF. This
service can throw exceptions. Currently they're automatically caught by
CXF and mapped to a SOAP fault, but I want to include additional
informations in the SOAP fault message.
I tried with CXF Soap11FaultOutInterceptor, but I only have a Message as
input; the original exception is not available.
It probably is. If you do message.getContent(Exception.class), it's probably
a Fault which has the cause set to your original exception. It MAY be
a "SoapFault" which would have a setter for the faultstring. If not, you
can call SoapFault.createSoapFault(fault) to convert the fault into a
soapfault and then set things as needed. You can do this in the faultOut
chain as early as possible.
However, there is a JAX-WS "standard" way of doing this, although it's a bit
convoluted. When you throw your exception, if you set the cause of your
exception to a javax.xml.ws.soap.SOAPFaultException, you can set all kinds of
things in the SOAPFault thing in there. The faultstring is one of them.
Dan
Thank you Dan. I'm going to explore a bit more if the message content
can take me back to the exception, in which case the CXF api is rich
enough to build a custom fault message.
For the second suggestion, I don't think it's applicable because my
exception can't be a SOAPFaultException : it is thrown by a specific
POJO layer that knows nothing about soap (but is called by the WS
layer). I don't want to mix transport specific classes with business
classes that may be reused with a different protocol. For the same
reason I don't want to introduce jax-ws annotations in this layer.
Pascal