java是SOAP Fault的detail元素中的结束信封标记吗?
我们正在将一个应用程序从Oracle Weblogic Portal 10.3.6迁移到Jetty。在此过程中,jaxws rt已升级到2.2.8版。之前我们使用的是嵌入Weblogic的版本,我认为它基于2.1.6或2.1.7版本
我们现在遇到的问题是,当JAX-WS试图解析来自我们正在使用的服务总线的一些SOAP错误时,会出现NullPointerException。解析失败的原因是,SOAP Fault包含封装在Fault detail元素中的整个原始响应消息,而SOAP消息则带有两个信封标记。当解析器到达第一个soap:envelope的末尾并尝试获取父节点时,它只返回null。它返回null,因为有一个“parentNode instanceof SOAPDocument”检查,即使parentNode是请求元素,也会返回true
根据http://schemas.xmlsoap.org/soap/envelope/的定义,detail元素可以包含任何内容
尽管它说detail元素可以包含任何内容,但将一个信封包装在另一个信封中是有效的SOAP,还是jaxws rt实现错误
这是无法解析的SOAP错误的一个示例:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>BEA-380001: Internal Server Error</faultstring>
<faultactor>dummy-code</faultactor>
<detail>
<mock>
<request>
<soap:Envelope>
<S:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
</S:Header>
<S:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
</S:Body>
</soap:Envelope>
</request>
<response>
<ns4:responseState xmlns:ns2="urn:srv.sag.enterprise.fs.edb.com:domain:element:v13_1" xmlns:ns4="urn:enterprise.fs.edb.com:domain:common:v1" xmlns:ns3="urn:srv.sag.enterprise.fs.edb.com:ws:element:v13_1" xmlns:ns9="urn:srv.agr.enterprise.fs.edb.com:domain:engagement:v14:2" xmlns:ns5="urn:srv.agr.enterprise.fs.edb.com:domain:engagement:v14:3" xmlns:ns6="urn:srv.agr.enterprise.fs.edb.com:domain:alertcodes:v1" xmlns:ns7="urn:srv.agr.enterprise.fs.edb.com:ws:engagement:v14_3" xmlns:ns8="urn:corews.enterprise.fs.edb.com:domain:common:v1">
<wsc:ErrorCode xmlns:wsc="http://mock.url/">68</wsc:ErrorCode>
<wsc:Severity xmlns:wsc="http://mock.url">2</wsc:Severity>
<wsc:ComponentId xmlns:wsc="http://mock.url">852</wsc:ComponentId>
<wsc:StrErrorCode xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsc="http://mock.url"/>
<wsc:Message xmlns:wsc="http://mock.url">Test message</wsc:Message>
<wsc:NativeError xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsc="http://mock.url"/>
<wsc:LogSequence xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsc="http://mock.url"/>
<wsc:errorItem key="LogRef" value="1425988364991" xmlns:wsc="http://mock.url"/>
</ns4:responseState>
</response>
</mock>
</detail>
</soap:Fault>
</soap:Body>
</soapenv:Envelope>
谢谢你的帮助
# 1 楼答案
我认为问题不在于嵌套的身体。这根本不是一个
<Fault>
,而是一个响应体。您只能有<Body>
或<Fault>
,不能两者都有,或者在这种情况下,<Body>
内的<Fault>
使这成为一个非故障SOAP响应,对于成功(非故障)响应来说,它可能不符合WSDL的模式把
<Fault>
作为<Envelope>
的子代和/或<Header>
的兄弟姐妹,你应该会做得更好,在模式方面