2012-12-17 7 views
5

JAX WS 2.0を使用してSOAP Webサービスを呼び出しています。SOAPFaultException.getFault()。getDetail()がnullです

私のクライアントで
<soap:Envelope> 
    <soap:Body> 
     <soap:Fault> 
      <detail> 

私が持っていたSoapFaultExceptionを取得しています:あなたは便利なエラーが、詳細ノードである見ることができるように

<?xml version="1.0"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap- envelope"> 
    <soap:Header/> 
    <soap:Body> 
     <soap:Fault xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap- envelope" xmlns:xml="http://www.w3.org/XML/1998/namespace"> 
      <soap:Code> 
       <soap:Value>soap:Receiver</soap:Value> 
      </soap:Code> 
      <soap:Reason> 
       <soap:Text xml:lang="en">Exception of type 'blah blah' was thrown. 
       </soap:Text> 
      </soap:Reason> 
      <soap:Node>{SOME URL}</soap:Node> 
      <detail> 
       <error>345</error> 
       <message>Cannot find user. Blah blah</message> 
      </detail> 
     </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

:エラーが発生した場合には、私は次のような応答を取得していますSOAPFaultオブジェクト。 SOAPFaultオブジェクトには、上記のノードがありません。 SOAPFaultException.getFault()。getDetail()がnullです。しかし、それは石鹸:理由を含む他のすべてのノードを持っています。なぜそれが詳細ノードを欠いているのか?

ありがとうございました。

答えて

3

詳細ノードにSOAP名前空間も含める必要があることが分かりました。私は、私は私のクライアントの中に注入カスタムSOAPHandlerののhandleFaultメソッドでこの変更を行うために管理Webサービスを制御できませんので

<soap:detail> 

:だから、する必要があります。その変更の後、障害の詳細はもはやヌルではなく、すべてのサブノードを持ちます。

http://www.w3.org/TR/soap12-part1/#soapfaultに基づいて、開発者はフォールト中に応答を修正する必要があると思います。

0

これが私の仕事:

} 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()); 
    } 

} 
関連する問題