user509755
user509755

Reputation: 2981

spring integration http outbound adapter not resolving properties

We are using http outbound adapter to make http get request and we want to read URL from properties file as it changes from envt to envt. We also append some other path to this url using message payload but then it is giving us this error message "Caused by: java.lang.IllegalArgumentException: Map has no value for URL". All we need is read base url from properties file and generate final url with payload.

Here is our sample config looks like

    <int-http:outbound-gateway request-channel="requestChannel"
                           url="${url}/{payload}"
                           http-method="GET"
                           expected-response-type="java.lang.String"
                           >

</int-http:outbound-gateway>

Upvotes: 2

Views: 491

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121542

Actually {payload} in your URL is an URI variable and it can't be resolved automatically. See how it works:

UriComponentsBuilder.fromUriString(uri).buildAndExpand(uriVariables)

Where uriVariables is a Map for those URI variables.

So, in your case the expected configuration must be like this:

<int-http:outbound-gateway request-channel="requestChannel"
                       url="${url}/{payload}"
                       http-method="GET"
                       expected-response-type="java.lang.String">
       <int-http:uri-variable name="payload" expression="payload"/>
</int-http:outbound-gateway>

More information you can find in the Reference Manual.

Upvotes: 2

Related Questions