如果是错误的soap请求,我需要获得错误的详细信息。
我正在使用JAX创建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服务客户端的任何配置吗?在此之前,非常感谢您。
发布于 2014-03-22 01:14:36
从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
}可以从这些构造中获得方法/信息,请参见相关的javadocs:
https://stackoverflow.com/questions/22474994
复制相似问题