简体   繁体   English

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

[英]JAX-WS SOAP Faults - parse the details of the error in a SOAPFaultException

I'm having the need to get the details of error if it's a faulty soap request. 如果这是一个错误的肥皂请求,我需要获取错误的详细信息。

I'm using JAX-WS to create web service client. 我正在使用JAX-WS来创建Web服务客户端。 My problem is that during a faulty transaction, the web service client is able to catch the SOAPFaultException but without detail: 我的问题是,在错误的事务中,Web服务客户端能够捕获SOAPFaultException但没有详细信息:

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

If I send the request through SOAPUI, I can get the response with details as: 如果我通过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>

Did I miss any configuration in web service client? 我是否错过了Web服务客户端中的任何配置? Many thanks in advance. 提前谢谢了。

To get details from the javax.xml.ws.soap.SOAPFaultException : 要从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
}

See associated javadocs for methods / info you can get from these constructs: 有关可从这些结构中获得的方法/信息,请参阅关联的javadoc:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM