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 > And I need it to extract > informations from this exception and build a custom Fault message. > > Basically what I have now is something like: > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <soap:Fault> > <faultcode>soap:Server</faultcode> > <faultstring>Fault occurred while processing.</faultstring> > </soap:Fault> > </soap:Body> > </soap:Envelope> > > And what I would like to get is: > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Body> > <soap:Fault> > <faultcode>soap:Server</faultcode> > <faultstring>1234|param1|param2|param3</faultstring> > </soap:Fault> > </soap:Body> > </soap:Envelope> > > Where the fault string is custom built using data extracted from the > initial exception. > > BTW I'm using CXF with Spring; don't know if it has an impact. > > Any help is welcome. > > Pascal -- Daniel Kulp [EMAIL PROTECTED] http://dankulp.com/blog
