gpt4 book ai didi

java - JAX-WS SOAP Faults - 解析 SOAPFaultException 中错误的详细信息

转载 作者:搜寻专家 更新时间:2023-10-31 19:38:47 25 4
gpt4 key购买 nike

如果是错误的 soap 请求,我需要获取错误的详细信息。

我正在使用 JAX-WS 创建 Web 服务客户端。我的问题是,在错误事务期间,Web 服务客户端能够捕获 SOAPFaultException 但没有详细信息:

javax.xml.ws.soap.SOAPFaultException: Component Interface API.    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)

如果我通过 SOAPUI 发送请求,我可以获得详细信息如下的响应:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">   <SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Component Interface API.</faultstring>
<detail>
<IBResponse type="Error">
<DefaultTitle>Integration Broker Response</DefaultTitle>
<StatusCode>20</StatusCode>
<MessageSetID>180</MessageSetID>
<MessageID>117</MessageID>
<DefaultMessage>You are allowed to claim one meal per day</DefaultMessage>
<MessageParameters>
<keyinformation>
<EMPLID>112233</EMPLID>
</keyinformation>
</MessageParameters>
</IBResponse>
</detail>
</SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

我是否遗漏了 Web 服务客户端中的任何配置?非常感谢。

最佳答案

要从 javax.xml.ws.soap.SOAPFaultException 中获取详细信息:

try {
//... invoke service via client
} catch (javax.xml.ws.soap.SOAPFaultException soapFaultException) {
javax.xml.soap.SOAPFault fault = soapFaultException.getFault(); //<Fault> node
javax.xml.soap.Detail detail = fault.getDetail(); // <detail> node
Iterator detailEntries = detail.getDetailEntries(); //nodes under <detail>
//application / service-provider-specific XML nodes (type javax.xml.soap.DetailEntry) from here
}

请参阅相关的 javadoc 以了解您可以从这些结构中获得的方法/信息:

关于java - JAX-WS SOAP Faults - 解析 SOAPFaultException 中错误的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22474994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com