2016-09-26 33 views
2

我有一個代碼訪問web服務而這又回到我的迴應Web服務集成 - 如何在響應類中訪問請求對象?

<int:chain input-channel="balanceChannel" output-channel="processedItems"> 
 
\t \t <int-ws:outbound-gateway destination-provider="myDestinationProvider" /> 
 
\t </int:chain> 
 
<int:service-activator input-channel="processedItems" 
 
\t \t ref="responseHandler" method="handleResponse" output-channel="nativeQlChannel" />

我能夠得到我的ResponseHandler所迴應,但我也想請求對象,我使用頻道發送到網絡服務?我如何在responseHandler中訪問相同的請求對象?

回答

0

好吧,因爲所有Spring集成端點都通過通道彼此分離,我們可以將它們視爲微服務。這真的是合乎邏輯和自然的,然後下一個端點對前一個端點的輸入一無所知。

無論如何,我們可以達到與消息標題的要求。所以,你請求負載複製到頭和可以訪問它的下游:

<int:header-enricher> 
    <int:header name="request" expression="payload"/> 
</int:header-enricher> 

您的服務方法handleResponse可以接受整個Message<?>獲得訪問該標題或你可以只添加一個方法PARAM用@Header("request")註釋。

+0

謝謝@ artem-bilan,它解決了我的問題。我可以在有效載荷中添加一些更多的值,記住它不應該發送到Web服務調用?任何方式來添加一些變量? –

相關問題