[英]JAX-WS SOAP Faults - parse the details of the error in a SOAPFaultException
如果這是一個錯誤的肥皂請求,我需要獲取錯誤的詳細信息。
我正在使用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:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.