Results 1 to 9 of 9

Thread: http pass through to a REST service

  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Default http pass through to a REST service

    I'm probably missing something obvious here but I can't see it and it's my first attempt at using Spring Integration.

    What I want to do is to receive an HTTP GET request, send it to a REST service and return the response.

    I've got the request being handed off the service working fine.

    The part that I can't get working is to return the response body - I've set the expected-response-type to java.lang.String but nothing is coming back (The response is XML)

    Config below.


    <bean class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="files">httpInbound</prop>
    </props>
    </property>
    </bean>

    <int-http:inbound-gateway id="httpInbound"
    reply-timeout="10000"
    request-channel="httpRequestChannel"
    reply-channel="httpReplyChannel"
    mapped-request-headers="HTTP_REQUEST_HEADERS, X-*"
    mapped-response-headers="HTTP_RESPONSE_HEADERS, X-*"
    extract-reply-payload="true"

    />

    <int-http:outbound-gateway id="httpOutbound"
    request-channel="httpRequestChannel"
    url="http://localhost:8080/myService/service/action"
    charset="UTF-8"
    reply-channel="httpReplyChannel"
    http-method="GET"
    expected-response-type="java.lang.String"
    mapped-request-headers="HTTP_REQUEST_HEADERS, X-*"
    mapped-response-headers="HTTP_RESPONSE_HEADERS, X-*">
    </int-http:outbound-gateway>

    <int:channel id="httpReplyChannel"/>

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Can you zip and post a log with the org.springframework.integration logger set to DEBUG?
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Apr 2012
    Posts
    3

    Default Debug log file

    Hi,
    Here is the log file

    Thanks,
    Ian
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Everything looks fine to me...

    Code:
    ...postSend (sent=true) on channel 'httpReplyChannel', message: [Payload=<?xml version=...
    What are you seeing on your client?
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5
    Join Date
    Apr 2012
    Posts
    3

    Default

    There is no data coming back from the server, however the (partial) header is as follows:

    < Content-Type: text/plain;charset=ISO-8859-1
    < Content-Length: 161
    <

    Some further info:
    I've got 3 services I'm trying to call like this and having tried a different one it works... - a bit more investigation shows that when I call these services directly the ones that don't work have the following header:
    < Server: Apache-Coyote/1.1
    < Content-Type: application/xml
    < Transfer-Encoding: chunked

    The one that does work has:
    < Server: Apache-Coyote/1.1
    < Content-Type: application/xml;charset=ISO-8859-1
    < Content-Language: en-GB
    < Content-Length: 3055938



    Thanks.
    Last edited by iwright; Apr 18th, 2012 at 02:46 AM.

  6. #6
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    I see you removed the comment about the bridge - it is an internal bridge to bridge from your httpReplyChannel to the channel in the message's replyChannel header.

    I believe the problem is the transfer-encoding header is being copied and confusing the client. From the log where the output message is being built...

    Code:
    setting headerName=[Transfer-Encoding], value=chunked
    You should be able to remove this header with a filter...

    Code:
    <header-filter input-channel="httpReplyChannel" output-channel="filteredHttpReplyChannel"
        header-names="Transfer-Encoding" />
    and change your input gateway's reply-channel to 'filteredHttpReplyChannel".

    We should probably not map that header on output; please open a JIRA issue.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  7. #7
    Join Date
    Jul 2012
    Location
    Cupertino, CA
    Posts
    24

    Default

    Any plans for fixing this?

    https://jira.springsource.org/browse/INT-2524

    Minor but annoying... Everywhere in the code I either have to put the filter tag or remove the header with java code...

  8. #8
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    We are going to address it for 2.2. Thanks for drawing our attention to it again.

    -Mark

  9. #9
    Join Date
    Jul 2012
    Location
    Cupertino, CA
    Posts
    24

    Default

    Thanks so much!

    Really looking forward to 2.2 - using 2.2 M4 already - I love the int:chain which supports embedding http:outbound-gateway!

Posting Permissions

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