2014-05-06 23 views
1

我正在使用JAX WS調用SOAP webservice。在我收到來自客戶端的操作響應中出現錯誤的情況下(我看到這在我的跟蹤日誌):SOAPFaultException明細爲空

<?xml version="1.0"?> 
<SOAP-ENV:Envelope xmlns:SOAP- ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<SOAP-ENV:Body> 
    <SOAP-ENV:Fault> 
     <faultcode>Error</faultcode> 
     <faultstring>Error</faultstring> 
     <SOAP-ENV:detail> 
      <BLAServiceFault xmlns:ns="http://messages.testservice.com/TestService/2012/10"> 
       <ns:ReturnStatus> 
        <ns:ReturnCode>-97</ns:ReturnCode> 
        <ns:ReturnStatusSpecification> 
         <ns:SubCode xsi:nil="true"/> 
         <ns:Description>The price of productA must be higher than 30.</ns:Description> 
        </ns:ReturnStatusSpecification> 
       </ns:ReturnStatus> 
      </BLAServiceFault> 
     </SOAP-ENV:detail> 
    </SOAP-ENV:Fault> 
</SOAP-ENV:Body> 

正如你可以看到有用的錯誤是在細部節點:

<SOAP-ENV:Envelope> 
<SOAP-ENV:Body> 
    <SOAP-ENV:Fault> 
     <SOAP-ENV:detail> 

在我的客戶端,我得到一個SOAPFaultException,它有一個SOAPFault對象。 SOAPFault對象似乎缺少我上面發佈的節點。 SOAPFaultException.getFault()。getDetail()爲null。異常爲javax.xml.ws.soap.SOAPFaultException:錯誤。我怎樣才能得到具有描述的細節節點?

謝謝。

回答

0

看起來來自該服務的消息不符合SOAP 1.1。在他們從'detail'節點刪除前綴'SOAP-ENV'後,它可以正常工作。

0

看看這個問題。 Possible to consume badly formed Fault Messages?

} catch (SoapFaultClientException e) { 
    log.error(e); 
    SoapFaultDetail soapFaultDetail = e.getSoapFault().getFaultDetail(); 
    SoapFaultDetailElement detailElementChild = (SoapFaultDetailElement) soapFaultDetail.getDetailEntries().next(); 
    Source detailSource = detailElementChild.getSource(); 

    try { 
     Object detail = (JAXBElement<SearchResponse>) getWebServiceTemplate().getUnmarshaller().unmarshal(detailSource); 
//    throw new SoapFaultWithDetailException(detail); 

    } catch (IOException e1) { 
     throw new IllegalArgumentException("cannot unmarshal SOAP fault detail object: " + soapFaultDetail.getSource()); 
    } 

}