SOAPFaultException详细信息为null

时间:2014-05-06 13:29:30

标签: java soap jax-ws websphere-7 soapfault

我使用JAX WS调用SOAP Web服务。在出现错误的情况下,我从客户端获得以下响应(我在跟踪日志中看到了这一点):

<?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>

正如您所看到的有用错误在详细信息节点中:

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

在我的客户端,我收到一个SOAPFaultException,它有一个SOAPFault对象。 SOAPFault对象似乎缺少我上面发布的节点。 SOAPFaultException.getFault()。getDetail()为null。例外是javax.xml.ws.soap.SOAPFaultException:错误。如何获得带描述的详细信息节点?

感谢。

2 个答案:

答案 0 :(得分:0)

来自服务的消息似乎不符合SOAP 1.1。在他们从'detail'节点中删除前缀'SOAP-ENV'后,它可以正常工作。

答案 1 :(得分:0)

看一下这个问题。 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());
    }

}
相关问题