简体   繁体   English

spring http出站网关定制

[英]spring http outbound gateway customization

My requirement is to call siebel soap webservice, In the process handle request and response on a same method call, so that I can add token to the request header from the apache common pool and once get the response with token, grab the token from response and send it to pool. 我的要求是调用siebel soap webservice,在进程句柄请求和响应上进行相同的方法调用,以便我可以从apache公共池向请求头添加令牌,一旦获得带令牌的响应,从响应中获取令牌并将其发送到池。 Here I have mechanism to verify old token too, I need request token and response token on same class. 这里我也有机制来验证旧令牌,我需要同一个类上的请求令牌和响应令牌。

Future planning to add retry mechanism. 未来计划添加重试机制。

Currently I am using SI Http outbound gateway. 目前我正在使用SI Http出站网关。

Any thoughts, appreciate it. 任何想法,欣赏它。

Thanks 谢谢

So, what you need is named pre- and post-process. 因此,您需要的是前后处理。 Not sure why you don't use Spring Integration WS support for calling that Siegel service, but even with the HTTP you can get a gain via Interceptor abstraction. 不确定为什么不使用Spring Integration WS支持来调用Siegel服务,但即使使用HTTP,您也可以通过Interceptor抽象获得收益。

What I mean that you can inject RestTemplate into HTTP Outbound Gateway supplied with the ClientHttpRequestInterceptor implementation to provide a desired logic. 我的意思是你可以将RestTemplate注入到ClientHttpRequestInterceptor实现提供的HTTP Outbound Gateway中,以提供所需的逻辑。

If you'd use WS Outbound Gateway, you could do that in the similar ClientInterceptor abstraction. 如果您使用WS Outbound Gateway,则可以在类似的ClientInterceptor抽象中执行此操作。

Of course, you can achieve that via HeaderMapper implementation, but that has different responsibility... 当然,您可以通过HeaderMapper实现实现这一目标,但这有不同的责任......

I found the way to achieve this, Created a class to extends HttpRequestExecutingMessageHandler than overrided handleRequestMessage() 我找到了实现这个目的的方法,创建了一个扩展HttpRequestExecutingMessageHandler的类,而不是覆盖handleRequestMessage()

http://docs.spring.io/spring-integration/reference/html/http.html#http-outbound http://docs.spring.io/spring-integration/reference/html/http.html#http-outbound

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM