web service integration - how to access request Object in response class?

雨燕双飞 提交于 2019-12-12 17:35:08

问题


i have a code to access the web-service which in turn return me a response

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

i am able to get response in my responseHandler , but i also want request object which i send to web-service using channel ? how can i access same request object in responseHandler ?


回答1:


Well, since all Spring Integration endpoints are decoupled from each other via channel and we can consider them as Microservices. And that is really logical and natural then the next endpoint knows nothing about the input of the previous one.

Anyway we can reach requirement with the message headers. So, you copy request payload to the headers and get access for it in the downstream:

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

Your service method handleResponse can accept the entire Message<?> to get access to that headers or your can just add one more method param with the @Header("request") annotation.



来源:https://stackoverflow.com/questions/39702545/web-service-integration-how-to-access-request-object-in-response-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!