SOAPFaultException.getFault().getDetail()为null

use*_*629 5 java soap jax-ws soapfault

我使用JAX WS 2.0调用SOAP Web服务.如果出现错误,我收到以下回复:

<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-   envelope">
    <soap:Header/>
    <soap:Body>
        <soap:Fault  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap- envelope" xmlns:xml="http://www.w3.org/XML/1998/namespace">
            <soap:Code>  
                <soap:Value>soap:Receiver</soap:Value>
            </soap:Code>
            <soap:Reason>
                <soap:Text  xml:lang="en">Exception of type 'blah blah' was thrown.
                </soap:Text>
            </soap:Reason>
            <soap:Node>{SOME URL}</soap:Node>
            <detail>
                <error>345</error>
                <message>Cannot find user. Blah  blah</message>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

您可以在详细信息节点中看到有用的错误:

<soap:Envelope>  
    <soap:Body>  
        <soap:Fault>  
            <detail>
Run Code Online (Sandbox Code Playgroud)

在我的客户端,我得到一个SOAPFaultException,它有一个SOAPFault对象.SOAPFault对象似乎缺少我上面发布的节点.SOAPFaultException.getFault().getDetail()为null.但是,它包含所有其他节点,包括soap:Reason.知道为什么它缺少细节节点吗?

谢谢.

use*_*629 3

事实证明,详细信息节点还需要包含 SOAP 命名空间。所以它需要是:

<soap:detail>
Run Code Online (Sandbox Code Playgroud)

由于我无法控制 Web 服务,因此我设法在注入客户端的自定义 SOAPHandler 的 handleFault 方法中进行此更改。更改后,故障详细信息不再为空,并且具有所有子节点。

基于http://www.w3.org/TR/soap12-part1/#soapfault,我相信开发人员需要在故障期间纠正响应。