On Monday, December 12, 2011 11:59:52 AM Malisetti, Ramanjaneyulu wrote:
> Hi
>      we have the  following code to create SoapFault for sending server side
> exception to client. On client side, detail part coming as Null. I see some
> posts in CXF forum on this issue and addressed as issue has been solved. We
> are using CXF 2.3.0
> 
> 
>            SOAPMessage response = msgFactory.createMessage();
>             CustomException cusEx = (CustomException) ((ex instanceof
> CustomException) ? ex
>                         : new CustomException
>                         : (ex));
> 
>             try {
>                   response.getSOAPBody().addNamespaceDeclaration("ns1",
>                               "http://com.test.ns1";);
>                   response.getSOAPBody().addNamespaceDeclaration("ns2",
>                               "http://com.test.ns2";);
> 
>                   WSAddressingUtil.addHeader(response,
> WSAddressingUtil.ACTION, WSTransferUtil.TRA_FAULT);
>                   SOAPFault fault = response.getSOAPBody().addFault();
>                   fault.setFaultActor("ns2:Sender");
>                   fault.setFaultCode("ns1:UnsupportedData");
>                   fault.setFaultString("The data specified on the request
> message is not supported " + "by the endpoint.");
>                   fault.addDetail().addTextNode(Util.getStackTrace(cusEx));
>             } catch (Exception e) {
>                   e.printStackTrace()
>             }
> 
> IS there anything wrong with this code?

Likely yes.    In almost all cases, the FaultCode should be soap:Server, not a 
custom name.    The detail should likely contain a DOM element using your 
custom fault qname and have the text content in there or similar.   Also, what 
are you then doing with the SOAPFault you are creating?    




-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to