DubMoth
DubMoth

Reputation: 23

Http inbound-gateway using optional request parameters

I want to find out if I'm missing something in relation to the http inbound-gateway. I want to perform a search (results will be json) using optional parameters. Below is an example of the defined gateway:

<int-http:inbound-gateway id="inboundSearchRequestGateway" supported-methods="GET, POST" request-channel="searchRequest" reply-channel="searchResults"
  mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS" view-name="/test123" path="/search" reply-timeout="50000"
  error-channel="errorChannel">
   <int-http:header name="param1" expression="#requestParams.param1"/>
   <int-http:header name="param2" expression="#requestParams.param2"/>
</int-http:inbound-gateway>

Currently I have to supply both parameters for the search to work otherwise the request is not passed onto the request channel.

The search in question is not using the parameters at the moment.

This will return results: http://localhost/test123/search?param1=123&param2=234

While this will return nothing: http://localhost/test123/search?param1=123

Is there any alternative way to map request parameters into integration message headers for further processing down the chain? Could this even be a bug?

I am using Spring Integration 4.1.2, Windows, Java 7.

Thanks.

T

Upvotes: 2

Views: 1205

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

Since requestParams is a Map, use #requestParams['param2'] for optional parameters. Using the dotted syntax requires the parameter to exist.

Upvotes: 2

Related Questions