Spring集成获取HTTP出站网关响应

Ale*_*ley 4 gateway transformer-model spring-integration payload

我需要POST一个REST服务调用并获取它返回的数据(所有这些都是使用JSON).我有一个出站网关,其回复通道作为链,链有一个变压器.

<int-http:outbound-gateway
    url="#{appProperties['rootUrl']}#{appProperties['myMethod']}"
    request-channel="myRequestChannel" reply-channel="myResponseChannel" >
</int-http:outbound-gateway>

<int:channel id="myResponseChannel"/>

<int:chain input-channel="myResponseChannel">
    <int:transformer ref="genericResponseTransformer"/>
</int:chain>
Run Code Online (Sandbox Code Playgroud)

但是当我通过变换器调试时,我得到的有效负载只是一个HttpStatus对象.

也许我做错了什么?任何帮助将不胜感激.谢谢!

omn*_*nom 9

如果未expected-response-type在网关中指定,则默认行为是响应消息仅包含状态代码(expected-response-type为null).尝试设置expected-response-type="java.lang.String":

<int-http:outbound-gateway
  url="#{appProperties['rootUrl']}"
  http-method="#{appProperties['myMethod']}"
  expected-response-type="java.lang.String"
  request-channel="myRequestChannel" reply-channel="myResponseChannel" />
Run Code Online (Sandbox Code Playgroud)