【问题标题】:How to get ResponseEntity body in spring-integration如何在 spring-integration 中获取 ResponseEntity 主体
【发布时间】:2018-11-10 04:17:25
【问题描述】:

我正在使用基于 xml 的配置 - 用于 trii=gger 休息服务的 http 出站网关,响应是 ResponseEntity,我不知道该服务的详细信息。我收到的输出应该放在 JMS 队列中。

如何更新以下内容以仅提取响应实体的主体并传递给输出通道?如果有变压器,请举例。是否可以使用配置?

<int:chain input-channel="gsInChannel" output-channel="dest-channel">
<int-http:outbound-gateway          
               url="https://ia-zatie.str13.tst.belst.nu/ia-zaatie/rest/signal/v2"
               http-method="POST"  
               header-mapper="headerMapper"
               request-factory="sslFactory"                
               >
</int-http:outbound-gateway>
    </int:chain>

dest-channel 是 jms:outbound-channel-adapter

启动版本 1.4.3 和集成版本 4.3.6

错误:org.springframework.messaging.MessageHandlingException:错误 发生在消息处理程序中 [org.springframework.integration.jms.JmsSendingMessageHandler#0]; 嵌套异常是 org.springframework.jms.support.converter.MessageConversionException: 无法转换类型的对象 [org.springframework.http.ResponseEntity] 到 JMS 消息。支持的 消息有效负载是:字符串、字节数组、映射、可序列化 对象。

【问题讨论】:

  • 添加了 expected-response-type="java.lang.String"
  • 听起来您已经找到了解决问题的方法。您可以这样回答并接受您自己的答案或完全关闭问题。

标签: rest spring-boot jms spring-integration spring-jms


【解决方案1】:

我使用的是 HTTP POST 方法,所以没想到会有响应。 SoO没有包含expected-response-type,返回body

<int-http:outbound-gateway          
               url="https://ia-zatie.str13.tst.belst.nu/ia-zaatie/rest/signal/v2"
               http-method="POST"  
               header-mapper="headerMapper"
               request-factory="sslFactory"  

               expected-response-type="java.lang.String">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-06
    • 2016-04-13
    相关资源
    最近更新 更多