Web服务集成 - 如何在响应类中访问请求对象?

问题描述 投票:2回答:1

我有一个访问网络服务的代码,反过来又给我一个回复

<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" />

我能够在我的responseHandler中得到响应,但我还想要使用通道发送到Web服务的请求对象?如何在responseHandler中访问相同的请求对象?

spring-integration spring-web
1个回答
0
投票

好吧,因为所有Spring Integration端点都通过通道相互分离,我们可以将它们视为微服务。这真的是合乎逻辑和自然的,然后下一个端点对前一个端点的输入一无所知。

无论如何,我们可以通过邮件标题达到要求。因此,您将请求有效负载复制到标头并在下游获取访问权限:

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

您的服务方法handleResponse可以接受整个Message<?>来访问该标题,或者您可以使用@Header("request")注释再添加一个方法参数。

© www.soinside.com 2019 - 2024. All rights reserved.