在Java 8_162中添加了错误的命名空间元素SOAPFault详细信息元素

时间:2018-03-02 20:18:42

标签: java soap jax-ws

我的应用程序正在使用JAX-WS,对于Java版本8_121,当SOAPFault发生时,一切都很好,响应生成如下:

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header>
        <Action xmlns="http://www.w3.org/2005/08/addressing" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" S:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</Action>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">A36AE1D2-B060-465D-9C7A-D5F40B2429BF</MessageID>
        <RelatesTo xmlns="http://www.w3.org/2005/08/addressing">ABCDE-12345-ABCDE</RelatesTo>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
    </S:Header>
    <S:Body>
        <S:Fault xmlns="" xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
            <faultcode>S:Client</faultcode>
            <faultstring>An error has occurred - please see the detail element for further information</faultstring>
            <detail>
                <itk:ToolkitErrorInfo xmlns="urn:hl7-org:v3" xmlns:itk="urn:nhs-itk:ns:201005">
                    <itk:ErrorID>ADF9356D-2191-4D2D-9649-2B4A7EEFA2AF</itk:ErrorID>
                    <itk:ErrorCode>3000</itk:ErrorCode>
                    <itk:ErrorText>Unable to process request</itk:ErrorText>
                    <itk:ErrorDiagnosticText>Client ID forbidden</itk:ErrorDiagnosticText>
                </itk:ToolkitErrorInfo>
            </detail>
        </S:Fault>
    </S:Body>
</S:Envelope>

但是,当我将Java版本带到8_164时,同一个应用程序输出:

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header xmlns="http://www.w3.org/2005/08/addressing" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
        <Action xmlns="http://www.w3.org/2005/08/addressing" S:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</Action>
        <MessageID>7A8D2AEE-37E5-4CD1-BFF7-957E59130EA2</MessageID>
        <RelatesTo>ABCDE-12345-ABCDE</RelatesTo>
        <To>http://www.w3.org/2005/08/addressing/anonymous</To>
    </S:Header>
    <S:Body xmlns="" xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
        <S:Fault>
            <faultcode>S:Client</faultcode>
            <faultstring>An error has occurred - please see the detail element for further information</faultstring>
            <detail xmlns="urn:hl7-org:v3" xmlns:itk="urn:nhs-itk:ns:201005">
                <itk:ToolkitErrorInfo xmlns:itk="urn:nhs-itk:ns:201005">
                    <itk:ErrorID>A70FE962-B17D-4DFF-A866-BC02AC73AB79</itk:ErrorID>
                    <itk:ErrorCode>3000</itk:ErrorCode>
                    <itk:ErrorText>Unable to process request</itk:ErrorText>
                    <itk:ErrorDiagnosticText>Client ID forbidden</itk:ErrorDiagnosticText>
                </itk:ToolkitErrorInfo>
            </detail>
        </S:Fault>
    </S:Body>
</S:Envelope>

JAX-WS似乎在“细节”中添加了额外的,不需要的命名空间。元素,所以对于8_121它是

<detail>

但对于8_162,它是

<detail xmlns="urn:hl7-org:v3" xmlns:itk="urn:nhs-itk:ns:201005">

这会阻止客户端JAX-WS代码正确解析SOAPFault,并且它会丢失detail元素。

该实现确实具有绑定注释来设置这些命名空间,但它们都是针对“详细信息”的包设置的。不在。我无法确定他们为什么被添加,并且只有在我超过121版本时才会确定。

是否有人知道可能导致这种情况的原因以及如何防止这种情况发生,或者如果不是这样,有关如何进一步诊断原因的任何提示?

1 个答案:

答案 0 :(得分:0)

好吧,既然什么都没有,我从来没有弄清楚这一点,但是我的解决方法,如果你发现自己在这里遇到类似的问题就是这样:

我在输出处理程序链中使用了一个处理程序来手动删除错误的名称空间声明。