views:

953

answers:

2

Hi,

How could I get the Fault Detail sent by a SoapFaultClientException ? I use a WebServiceTemplate as shown below :

WebServiceTemplate ws = new WebServiceTemplate();
ws.setMarshaller(client.getMarshaller());
ws.setUnmarshaller(client.getUnMarshaller());
try {
    MyResponse resp = (MyResponse) = ws.marshalSendAndReceive(WS_URI, req);
} catch (SoapFaultClientException e) {
     SoapFault fault =  e.getSoapFault();
     SoapFaultDetail details = e.getSoapFault().getFaultDetail();
      //details always NULL ? Bug?
}

The Web Service Fault sent seems correct :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
<soapenv:Body>
  <soapenv:Fault>
     <faultcode>soapenv:Client</faultcode>
     <faultstring>Validation error</faultstring>
     <faultactor/>
     <detail>
        <ws:ValidationError xmlns:ws="http://ws.x.y.com"&gt;ERR_UNKNOWN&lt;/ws:ValidationError&gt;
     </detail>
  </soapenv:Fault>
</soapenv:Body>

Thanks

Willome

+1  A: 

From the Javadocs for the marshalSendAndReceive method it looks like the SoapFaultClientException in the catch block will never happen.

From the API it looks like the best bet for determining the details of the fault is to set a custom Fault Message Receiver.

John Meagher
A: 

Problem was coming from the JAXB Libraries