JAX-WS SOAP Faults-解析SOAPFaultException中的错误的详细信息 [英] JAX-WS SOAP Faults - parse the details of the error in a SOAPFaultException

查看:170
本文介绍了JAX-WS SOAP Faults-解析SOAPFaultException中的错误的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果是错误的肥皂请求,我需要获取错误的详细信息.

I'm having the need to get the details of error if it's a faulty soap request.

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

I'm using JAX-WS to create web service client. My problem is that during a faulty transaction, the web service client is able to catch the SOAPFaultException but without detail:

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

如果我通过SOAPUI发送请求,则可以获得以下响应:

If I send the request through SOAPUI, I can get the response with details as:

<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服务客户端中的任何配置?预先非常感谢.

Did I miss any configuration in web service client? Many thanks in advance.

推荐答案

要从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:

See associated javadocs for methods / info you can get from these constructs:

  • SoapFaultException
  • SOAPFault
  • Detail
  • DetailEntry

这篇关于JAX-WS SOAP Faults-解析SOAPFaultException中的错误的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆