I am calling int-http:outbound-gateway for external service call which looks like this, http://workflow-test-svc-stg.com/workflow?testId=1234&userId=ABC
But I don't have int-http:inbound-gateway to set request param as
<int-http:header name="testId" expression="#requestParams[testId]"/>
<int-http:header name="userId" expression="#requestParams[userId]"/>
I am using request channel send method to send url(http://workflow-test-svc-stg.com/workflow) and headers(testId and userId) to call above external service but I am not sure how to tell outbound gateway that testId and userId need to be request params.
I tried using
<int:gateway id="requestGateway"
default-request-channel="request.channel">
<int:default-header name="testId" expression="headers.testId" />
<int:default-header name="userId" expression="headers.userId" />
</int:gateway>
<int-http:outbound-gateway id="driverWorkloadGateway"
request-channel="request.channel"
url-expression="headers.bstUrl"
http-method="GET"
expected-response-type="java.lang.String"
charset="UTF-8"
request-factory="httpComponentClientRequestFactory"
mapped-request-headers="*" >
<int-http:uri-variable name="testId" expression="#requestParams[testId]"/>
<int-http:uri-variable name="userId" expression="#requestParams[userId]"/>
</int-http:outbound-gateway>
can you please help?
We have that explained in the docs: https://docs.spring.io/spring-integration/docs/current/reference/html/http.html#mapping-uri-variables
And the sample demonstrates how that supposed to be:
Pay attention to that
{zipCode}placeholder.So, for your use-case that
headers.bstUrlmust have thosetestIdanduserIdplaceholders. You also need to change a#requestParamsSpEL variable to theheadersproperty reference.That
<int:default-header name="testId" expression="headers.testId" />definition also looks suspicious. Why would one overrides the header with its own value?