0

In Spring-integration Http request based on user logged in want to add dynamic header param.say for example if "A" user logged in & hitHttp request,now need to add dynamic 1 additional header,for others user,it should even the key too(i.e value as null)

For A user

<int:gateway id="requestGateway" service-interface="net.group.gateway.Gateway"  default-request-channel="jsonTransformationChannel">
            <int:default-header name="X-MW-LOGGEDID" expression="@requestData.getLoggedID()" />
            <int:default-header name="X-Srcvalue" value="56789" />
            <int:default-header name="content-type" value="application/json" />
            <int:default-header name="Accept" value="application/json" />
</int:gateway>

For Other user

<int:gateway id="requestGateway" service-interface="net.group.gateway.Gateway"  default-request-channel="jsonTransformationChannel">
            <int:default-header name="X-MW-LOGGEDID" expression="@requestData.getLoggedID()" />
            <int:default-header name="content-type" value="application/json" />
            <int:default-header name="Accept" value="application/json" />
 </int:gateway>
Doss
  • 31
  • 1
  • 14

1 Answers1

0

I guess the story is really about that X-Srcvalue. And since you say it's OK to null for anyone else, that would better to use an expression instead of value.

<int:default-header name="X-Srcvalue" expression="USER == A ? 56789 : null" />

In the expression you can use any bean in the application context to perform the logic any complexity.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • my problem,if other user logged in,under header the key itself "X-Srcvalue" should not present.for A user is not a prblm. – Doss Mar 21 '18 at 18:21
  • Well, the point is if value of that header to map is `null` it isn't going to be presented in the output message. See `MessageHeaderAccessor.setHeader()` implementation – Artem Bilan Mar 21 '18 at 18:28