2017-04-12 79 views
1

我有這樣的駱駝航線:駱駝和CXF:如何獲取出站郵件?

from("cxf:bean:endpointDocs01?loggingFeatureEnabled=true") 
    .to("direct:CBR") 
    .transform().method(WebServiceUtils.class,"response()") 
    .log("Outbound message: ${body}"); 

endpointDocs01在藍圖定義是這樣的:

<cxf:cxfEndpoint address="/documentos/" id="endpointDocs01" 
    serviceClass="com.adelco.webservice.ServiceDocs" wsdlURL="wsdl/wsdl03.wsdl"> 
    <cxf:properties> 
     <entry key="schema-validation-enabled" value="true"/> 
    </cxf:properties> 
</cxf:cxfEndpoint> 

這條路線的作品,沒有任何問題,包括架構驗證。

當我送一個正確的請求,我可以用交換的最後一行的「.LOG(」做「事」(在這種情況下記錄)出站消息:$ {機構}」在這種情況下,日誌顯示此:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <outputDocumento xmlns="http://webservice.adelco.com"> 
     <respuesta>0</respuesta> 
     <mensaje>El mensaje [113282] fue recibido. Fecha recepción Wed Apr 12 17:01:11 CLT 2017</mensaje> 
     </outputDocumento> 
    </soap:Body> 
</soap:Envelope> 

但是,當我發送一個不正確的請求,該行」 .LOG(‘日誌傳出消息:$ {機構}’什麼也不做不過我得到了客戶端的響應(一肥皂:故障響應)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
     <soap:Fault> 
      <faultcode>soap:Client</faultcode> 
      <faultstring>Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Sociedad'. One of '{"http://webservice.adelco.com":TipoMovimiento}' is expected.</faultstring> 
     </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

爲什麼這個soap:故障響應不是logge d?

+0

你能更好地解釋一下你的捕捉是什麼意思? CXF具有用於記錄您可以打開的輸入和輸出的功能 –

回答

3

您的路線被調用反編組。因此,如果解組因無效輸入而失敗,則路由不會觸發並且不會記錄。

閱讀關於CXF architecture的文章。

階段攔截
CXF提供InterceptorChain實現稱爲PhaseInterceptorChain。 [...]
讓我們以一個假設的簡化示例(注意:這些階段和攔截器不一定存在於CXF中)。讓我們說我們正在解析一個SOAP消息。我們可能想要分兩個階段。首先,調度階段分析肥皂標題並確定將消息路由到哪個服務。其次,將SOAP主體綁定到JAXB對象的解組階段。
故障處理
在處理過程中的任何時候,攔截器可能會拋出一個故障或像SoapFault一樣的故障派生。這將導致鏈停止調用並展開它。展開包括對以相反順序調用的每個攔截器調用handleFault。

當發生故障時,處理停止並且攔截器鏈展開。 CXF對消息使用不同的鏈(在&輸出中)和故障(在&輸出中)。

要使用自定義豆(必須實現PhaseInterceptor接口)作爲攔截器:

<cxf:cxfEndpoint address="/documentos/" id="endpointDocs01" 
    serviceClass="com.adelco.webservice.ServiceDocs" wsdlURL="wsdl/wsdl03.wsdl"> 
    <cxf:properties> 
     <entry key="schema-validation-enabled" value="true"/> 
    </cxf:properties> 
    <cxf:inInterceptors> 
     <ref component-id="inInterceptorBean" /> 
    </cxf:inInterceptors> 
    <cxf:outInterceptors> 
     <ref component-id="outInterceptorBean" /> 
    </cxf:outInterceptors> 
    <cxf:outFaultInterceptors> 
     <ref component-id="outFaultInterceptorBean" /> 
    </cxf:outFaultInterceptors> 
</cxf:cxfEndpoint>