Results 1 to 5 of 5

Thread: Content-Length in http:inbound-gateway Reply Channel

  1. #1
    Join Date
    Aug 2007
    Posts
    138

    Default Content-Length in http:inbound-gateway Reply Channel

    I have a simple REST service provided by SI 2.0.5 that takes a JSON request through an http:inbound-gateway, does some processing in a POJO service activator, and sends out a JSON reply through the gateway. I am finding that the JSON is cut off in the middle; it is the same length as the request.

    I added a header-filter as follows:

    Code:
    <http:inbound-gateway id="inboundGateway"
                              request-channel="requestChannel"
                              reply-channel="replyChannel"
                              name="/documents/messages"
                              supported-methods="POST"
                              request-payload-type="com.myapp.MyClass"
                              message-converters="messageConverterList"/>
    <service-activator ref="serviceDelegate"
                           input-channel="requestChannel"
                           output-channel="headerFilterChannel"/>
    <header-filter input-channel="headerFilterChannel"
                       output-channel="replyChannel"
                       header-names="Content-Length"/>
    And yet the Content-Length header is in the response, and its value remains the same as the request's.

    Any insight into how to resolve this is appreciated.

  2. #2
    Join Date
    Aug 2007
    Posts
    138

    Default

    It turns out mapped-response-headers="Content-Type" to the inbound-gateway solved the issue. I would love an explanation just to understand the reason.

    Thanks.

  3. #3
    Join Date
    Dec 2010
    Posts
    315

    Default

    I have an issue similar to yours but it has nothing to do with content type.

    Can you tell me what converters did you declare for:
    Code:
    message-converters="messageConverterList
    For your service activator, what is the type of the payload released to the headerFilterChannel?
    Code:
    <service-activator ref="serviceDelegate"
                           input-channel="requestChannel"
                           output-channel="headerFilterChannel"/>
    For the inbound-gateway to send a JSON reply, I expect you have Jackson in your classpath? In the docs, it's mentioned you have to declare a ViewResolver. What ViewResolver did you declare if any?

    Thanks

  4. #4

    Default

    Quote Originally Posted by neilac333 View Post
    It turns out mapped-response-headers="Content-Type" to the inbound-gateway solved the issue. I would love an explanation just to understand the reason.

    Thanks.
    I had the same exact issue and adding the "mapped-response-headers" attribute to the inbound-gateway solved it. Did you ever find the root cause to this?

    -Thanks

  5. #5
    Join Date
    Jun 2012
    Posts
    11

    Default

    I'm experiencing the same behavior with SI 2.1.2.RELEASE and the spring-integration-samples basic http project. I modified the inboud-gateway as follows:

    HTML Code:
    	<int-http:inbound-gateway request-channel="receiveChannel"
                              reply-channel="responseChannel"
                              name="/receiveGateway"
                              view-name="/receiveGateway"
                              supported-methods="POST"/>
                              <!--mapped-response-headers="Content-Type"-->
    
    
        <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
            <property name="mediaTypes">
                <map>
                    <entry key="json" value="application/json"/>
                </map>
            </property>
            <property name="defaultViews">
                <list>
                    <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
                </list>
            </property>
        </bean>

    When I add the mapped-response-headers line, the content-length header is not included and the response is received correctly. Without it my content-length is the size of the request, and the response is truncated.

    Any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •