MyGateway(defined in service-interface) is a Interface will contain one request body(JsonFormat) which I will be passing it in http-outbound-gateway for rest call
<!-- Gateway -->
<int:gateway id="requestGateway"
service-interface="com.spring.example.MyGateway"
default-request-channel="requestChannel12345"/>
<int:channel id="requestChannel12345"/>
<bean id="methodInsideService" class="com.spring.example.ServiceImpl"/>
Using below Service-Activator I created one model class which will contains values of headers so that I can use dynamic headers while doing a rest call ---> below
<int:service-activator input-channel="requestChannel12345"
output-channel="responseChannel1234567"
ref="methodInsideService"
method="methodExample"/>
<bean id="clientHttpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"/>
Here I am accepting request channel(responseChannel1234567) as outpt-channel(responseChannel1234567) of dynamic headers response ---> here my actual json request overwritten with headers payload which I am creating to use it as dynamic header values
<int:chain input-channel="responseChannel1234567" >
<int:header-enricher>
<int:header name="header1" expression="payload.getheader1()" ></int:header>
<int:header name="header2" expression="payload.getheader2()" ></int:header>
<int:header name="header3" expression="payload.getheader3()" ></int:header>
</int:header-enricher>
<int-http:outbound-gateway
id="requestGateway"
url="http://localhost/test?queryParam1={queryParam1}&queryParam2={queryParam2}&queryParam3={queryParam3}"
http-method="POST"
request-factory="clientHttpRequestFactory"
header-mapper="headerMapper12345"
expected-response-type="java.lang.String">
<int-http:uri-variable name="queryParam1" expression="payload.getqueryParam1()"/>
<int-http:uri-variable name="queryParam2" expression="payload.getqueryParam2()"/>
<int-http:uri-variable name="queryParam3" expression="payload.getqueryParam3()"/>
</int-http:outbound-gateway>
</int:chain>
<bean id="headerMapper12345" class="org.springframework.integration.http.support.DefaultHttpHeaderMapper">
<property name="outboundHeaderNames" value="HTTP_REQUEST_HEADERS, header1,header2,header3" />
<property name="userDefinedHeaderPrefix" value="" /></bean>
</beans>
Now My Question is how to pass multiple headers(dynamic will pass at code level),multiple query-params(dynamic at code level) and request body(JSON Format) to make a rest call to other services. Request body we can pass from Interface, but how to pass the headers and query params from interface or using service-activator and then configure xml accordingly to make a rest http outbound gateway call to other rest endpoint. Thanks in advance