2012-02-15 69 views
4

我需要POST一个REST服务调用并获取它返回的数据(所有这些都与JSON)。我有一个出站网关,它的回复通道作为一个链条,链条上有一个变压器。Spring集成获取HTTP出站网关响应

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

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

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

回答

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

工作就像一个魅力,谢谢! – 2012-02-15 20:01:36