【问题标题】:Spring integration Inbound Http gateway chunking json response for POST requestSpring集成入站Http网关分块json响应POST请求
【发布时间】:2015-11-24 17:22:47
【问题描述】:

我正在尝试使用 spring 集成的入站 http 网关。下面是我的配置。

<int:channel id="requestChannel" />
<int:channel id="responseChannel" />


<int-http:inbound-gateway id="inboundEmployeeSearchRequestGateway"
    supported-methods="POST" request-channel="requestChannel"
    reply-channel="responseChannel"
    mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
     path="/services/{parama}/{paramb}/search"
    reply-timeout="6000000000">

    <int-http:header name="parama" expression="#pathVariables.parama" />
    <int-http:header name="paramb" expression="#pathVariables.paramb" />

</int-http:inbound-gateway>



<int:service-activator id="activator"
    input-channel="requestChannel" output-channel="responseChannel"
    ref="execSearch" method="execute" requires-reply="true"
    send-timeout="6000000000" />

我的服务激活码如下:

@Service
public class ExecutionService {

    @Autowired
    private AppDao appDao;

    public SQLResponse execute(Message<?> msg) throws Exception {
        SQLResponse response = new SQLResponse();
        Map<String,String> map = new HashMap<>();
        map.put("name","test");
        response.setResult(map);
        return response;
    }
}

但是我的响应越来越多,只有当我使用 POST 使用服务时才会发生这种情况,而 GET 功能非常好。请帮忙

【问题讨论】:

    标签: json spring-boot spring-integration


    【解决方案1】:

    什么应用服务器?我刚刚尝试使用 Tomcat 和 Jackson 消息转换器将地图转换为 JSON,但它不适合我。

    您使用的是哪个消息转换器?

    无论如何分块有什么问题?

    【讨论】:

    • 您好,我正在使用 tomcat,该应用程序是基于 Spring Boot 的。以下链接帮助我解决了这个问题。 forum.spring.io/forum/spring-projects/integration/… 。但我不需要提及链接中描述的任何视图解析器。只需将 mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS" 更改为 mapped-response-headers="Content-Type"
    【解决方案2】:

    我正在使用 tomcat 并且该应用程序是基于 Spring boot 的。以下链接帮助我解决了这个问题。 http://forum.spring.io/forum/spring-projects/integration/109102-content-length-in-http-inbound-gateway-reply-channel 。但我不需要提及链接中描述的任何视图解析器。只需将 ma​​pped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS" 更改为 ma​​pped-response-headers="Content-Type" 即可入站网关

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-25
      相关资源
      最近更新 更多