Spring Integration
  1. Spring Integration
  2. INT-1677

Ability to access parameters from HTTP GET inbound requests when constructing outbound calls

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 2.0 Final
    • Fix Version/s: 2.1 M1
    • Component/s: Web Services
    • Labels:
      None

      Description

      REST HTTP GET requests contain parameters in the path and in the query string. Currently, Spring Integration captures path parameters like id in the following example

      <http:inbound-gateway     id="documentByIdInboundGateway"
                                request-channel="documentByIdRequestChannel"
                                reply-channel="documentByIdReplyChannel"
                                name="/documents/{id}"
                                supported-methods="GET"/>
      
      DEBUG [BeanNameUrlHandlerMapping.lookupHandler] Matching patterns for request [/documents/1232332] are [/documents/{id}]
      DEBUG [BeanNameUrlHandlerMapping.lookupHandler] URI Template variables for request [/documents/1232332] are {id=1232332}
      
      

      However, it is impossible to access these URI template variables in order to construct an outbound call from them. The is a feature request for an API to retrieve the id from above for the following outbound call for example:

      <http:outbound-gateway     id="documentByIdTargetAdapter"
                                 url="http://localhost:8080/myapp/documents/{id}"
                                 http-method="GET"
                                 request-channel="documentByIdRequestChannel"
                                 reply-channel="targetDocumentByIdReplyChannel"
                                 expected-response-type="com.myapp.Document"
                                 charset="UTF-8"
                                 header-mapper="jsonHeaderMapper">
      

      Of course, the outbound request could be of any kind and not just a REST call.

      Incidentally, it is unclear what the current Spring Integration behavior is for query parameters. Regardless, this feature request applies to all inbound REST parameters.

        Issue Links

          Activity

          Hide
          Tom Greasley added a comment -

          I recently made small changes to a copy of HttpRequestHandlingEndpointSupport such that the query params and URI template variables were added to the message header rather than the body, regardless of the method GET or POST. It made things a lot more flexible. The only thing I was not happy with was not being able to create a null message body for GET requests, I used a new Object() instead.

          Show
          Tom Greasley added a comment - I recently made small changes to a copy of HttpRequestHandlingEndpointSupport such that the query params and URI template variables were added to the message header rather than the body, regardless of the method GET or POST. It made things a lot more flexible. The only thing I was not happy with was not being able to create a null message body for GET requests, I used a new Object() instead.
          Hide
          Andrew Berman added a comment -

          Is there any movement on this issue? I've run into the same thing where I need to get the parameter from the URL. I see the request URL, but like the reporter mentioned in the forum, it's really clunky to be parsing that in the context xml. Ideally, something like pathParams["myparam"] would be perfect.

          Show
          Andrew Berman added a comment - Is there any movement on this issue? I've run into the same thing where I need to get the parameter from the URL. I see the request URL, but like the reporter mentioned in the forum, it's really clunky to be parsing that in the context xml. Ideally, something like pathParams ["myparam"] would be perfect.
          Hide
          Oleg Zhurakousky added a comment -

          Actually I've been looking into that and similar requirement recently, so we'll do something with it for 2.1. Meanwhile you can add transformer in between the inbound and outbound and extract the required values.

          Show
          Oleg Zhurakousky added a comment - Actually I've been looking into that and similar requirement recently, so we'll do something with it for 2.1. Meanwhile you can add transformer in between the inbound and outbound and extract the required values.
          Hide
          Vigil Bose added a comment -

          This feature is very crucial for our project since we have a collection of REST based Spring Integration powered services that cater to various requests from different clients. So look forward to having a clean solution to extract URI variables from the inbound http gateway or inbound http adapter.

          Show
          Vigil Bose added a comment - This feature is very crucial for our project since we have a collection of REST based Spring Integration powered services that cater to various requests from different clients. So look forward to having a clean solution to extract URI variables from the inbound http gateway or inbound http adapter.
          Hide
          Oleg Zhurakousky added a comment -

          This might have already been resolved as part of INT-1349.

          <int-http:outbound-channel-adapter id="fullConfig"
          			url="http://localhost/test2/{foo}"
          			http-method="GET"
          			. . .">
          		<int-http:uri-variable name="foo" expression="headers.bar"/>
          </int-http:outbound-channel-adapter>
          

          Please take a look and let us know

          Show
          Oleg Zhurakousky added a comment - This might have already been resolved as part of INT-1349 . < int -http:outbound-channel-adapter id= "fullConfig" url= "http: //localhost/test2/{foo}" http-method= "GET" . . ."> < int -http:uri-variable name= "foo" expression= "headers.bar" /> </ int -http:outbound-channel-adapter> Please take a look and let us know
          Hide
          Mark Fisher added a comment -

          The requirement for this issue is actually related to inbound requests.

          Show
          Mark Fisher added a comment - The requirement for this issue is actually related to inbound requests.
          Hide
          Oleg Zhurakousky added a comment -

          The example below shows how it could be accomplished.

          <inbound-channel-adapter id="inboundAdapterWithExpressions" 
          	                         path="/fname/{f}/lname/{l}"
          	                         channel="requests"
          							 mapped-request-headers="foo,bar"
          							 payload-expression="#pathVariables.f">
          		<header name="lname" expression="#pathVariables.l"/>
          	</inbound-channel-adapter>
          
          Show
          Oleg Zhurakousky added a comment - The example below shows how it could be accomplished. <inbound-channel-adapter id= "inboundAdapterWithExpressions" path= "/fname/{f}/lname/{l}" channel= "requests" mapped-request-headers= "foo,bar" payload-expression= "#pathVariables.f" > <header name= "lname" expression= "#pathVariables.l" /> </inbound-channel-adapter>

            People

            • Assignee:
              Oleg Zhurakousky
              Reporter:
              Neil Chaudhuri
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: