Spring Integration 获取 HTTP 出站网关响应

发布于 2025-01-06 03:03:34 字数 577 浏览 4 评论 0原文

我需要 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>

但是,当我通过变压器进行调试时,我返回的有效负载只是一个 HttpStatus 对象。

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

I need to POST a REST service call and get the data it returns (all of this is with JSON). I have an outbound-gateway with its reply-channel as a chain, and the chain has one transformer.

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

However when I debug through the transformer, the payload I get back is just an HttpStatus object.

Maybe I'm doing something wrong? Any help would be greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没结果 2025-01-13 03:03:34

如果您未在网关中指定 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" />

If you do not specify expected-response-type in your gateway, the default behavior is that the response message contains only status code (expected-response-type is null). Try setting 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" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文