I am trying to add custom headers to my http outbound gateway.
Things that I have tried & work:
<int:header-enricher>
<int:header name="replyChannel" value="nullChannel" />
<int:header name="Content-Type" value="application/xml" />
<int:header name="X-Operation" value="CUSTOM_OPERATION" />
<int:header name="X-StatusCode" value="200" />
</int:header-enricher>
<int-http:outbound-gateway url="${custom.url}/update"
mapped-request-headers="HTTP_REQUEST_HEADERS, Operation, StatusCode"
http-method="POST" request-factory="serviceRequestFactory"
expected-response-type="java.lang.String"
error-handler="errorChannelHandler" />
In the above scenario, it works but the custom headers that I add, are prefixed with X- by default.
To get rid of it, I tried the following but it doesn't set my custom values to the headers:
<int:header-enricher>
<int:header name="replyChannel" value="nullChannel" />
<int:header name="Content-Type" value="application/xml" />
<int:header name="Operation" value="CUSTOM_OPERATION" />
<int:header name="StatusCode" value="200" />
</int:header-enricher>
<int-http:outbound-gateway url="${custom.url}/update"
header-mapper="headerMapper"
http-method="POST" request-factory="serviceRequestFactory"
expected-response-type="java.lang.String"
error-handler="errorChannelHandler" />
<bean id="headerMapper" class="org.springframework.integration.http.support.DefaultHttpHeaderMapper">
<property name="inboundHeaderNames" value="*"/>
<property name="outboundHeaderNames" value="HTTP_REQUEST_HEADERS, Operation, StatusCode" />
<property name="userDefinedHeaderPrefix" value=""/>
</bean>
After spending a lot of time in trying to fix this, I am stuck. Any help would be appreciated.
I just tested your mapper with the sample app and it worked fine...
Turn on DEBUG logging for
org.springframework.integration
to get detailed logging for header mapping...