我正在使用 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:错误。如何获取带有描述的详细节点?
谢谢。
最佳答案
来自该服务的消息似乎不符合 SOAP 1.1 标准。当他们从“detail”节点中删除前缀“SOAP-ENV”后,它就可以正常工作了。
关于java - SOAPFaultException 详细信息为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23496112/