Announcement Announcement Module
Collapse
No announcement yet.
http pass through to a REST service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Can you zip and post a log with the org.springframework.integration logger set to DEBUG?

    Comment


    • #3
      Debug log file

      Hi,
      Here is the log file

      Thanks,
      Ian

      Comment


      • #4
        Everything looks fine to me...

        Code:
        ...postSend (sent=true) on channel 'httpReplyChannel', message: [Payload=<?xml version=...
        What are you seeing on your client?

        Comment


        • #5
          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, 03:46 AM.

          Comment


          • #6
            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.

            Comment


            • #7
              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...

              Comment


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

                -Mark

                Comment


                • #9
                  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!

                  Comment

                  Working...
                  X