1

I am calling a SOAP webservice using JAX WS. In the case of an error I am getting the following response from the client (I see this in my trace log):

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP- ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
    <SOAP-ENV:Fault>
        <faultcode>Error</faultcode>
        <faultstring>Error</faultstring>
        <SOAP-ENV:detail>
            <BLAServiceFault xmlns:ns="http://messages.testservice.com/TestService/2012/10">
                <ns:ReturnStatus>
                    <ns:ReturnCode>-97</ns:ReturnCode>
                    <ns:ReturnStatusSpecification>
                        <ns:SubCode xsi:nil="true"/>
                        <ns:Description>The price of productA must be higher than 30.</ns:Description>
                    </ns:ReturnStatusSpecification>
                </ns:ReturnStatus>
            </BLAServiceFault>
        </SOAP-ENV:detail>
    </SOAP-ENV:Fault>
</SOAP-ENV:Body>

As you can see the useful error is in the detail node:

<SOAP-ENV:Envelope>  
<SOAP-ENV:Body>  
    <SOAP-ENV:Fault>  
        <SOAP-ENV:detail>

In my client I am getting a SOAPFaultException which has a SOAPFault object. The SOAPFault object seems to be missing the node I posted above. SOAPFaultException.getFault().getDetail() is null.The exception is javax.xml.ws.soap.SOAPFaultException: Error. How can i get the detail node with description?

Thanks.

2 Answers 2

0

It appears that the message that came from the service was not SOAP 1.1 compliant. After they have removed the prefix 'SOAP-ENV' from the 'detail' node it works fine.

Sign up to request clarification or add additional context in comments.

Comments

0

Take a look at the question. Possible to consume badly formed Fault Messages?

} catch (SoapFaultClientException e) {
    log.error(e);
    SoapFaultDetail soapFaultDetail = e.getSoapFault().getFaultDetail();
    SoapFaultDetailElement detailElementChild = (SoapFaultDetailElement) soapFaultDetail.getDetailEntries().next();
    Source detailSource = detailElementChild.getSource();

    try {
        Object detail = (JAXBElement<SearchResponse>) getWebServiceTemplate().getUnmarshaller().unmarshal(detailSource);
//                throw new SoapFaultWithDetailException(detail);

    } catch (IOException e1) {
        throw new IllegalArgumentException("cannot unmarshal SOAP fault detail object: " + soapFaultDetail.getSource());
    }

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.