Announcement Announcement Module
Collapse
No announcement yet.
http outbound gateway custom headers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • http outbound gateway custom headers

    I have java object that I would like to pass as a custom header to my request on the http outbound gateway. Below is a snippet -

    <int:gateway id="service" service-interface="MyService" default-request-channel="requestChannel" default-reply-channel="replyChannel">
    <int:method name="doSomething" payload-expression="#args[0] + ',' + #args[1]">
    <int:header name="method_name" value="login"/>
    <int:header name="service_identifier" value="myService"/>
    </int:method>
    </int:gateway>

    <int:header-enricher input-channel="requestChannel" output-channel="gatewayChannel">
    <int:header name="user_context" expression="T(UserContextHolder).getContext()"/>
    </int:header-enricher>

    <int-http:outbound-gateway request-channel="gatewayChannel" url="myURL" mapped-request-headers="user_context, service_identifier, method_name, HTTP_REQUEST_HEADERS" http-method="POST" reply-channel="replyChannel"/>


    Where UserContext could be a java object

    UserContext implements Serializable {
    String userId;
    RequestParameters params;
    ScopeEnum scope;
    ....
    }


    The problem I have is header user_context is not mapped in the header. From the logs, I can see that the DefaultHttpHeaderMapper is requesting for a Converter or ConversionService -

    09:54:59,488 - WARN main org.springframework.integration.http.support.Defau ltHttpHeaderMapper - Header 'X-user_context' with value 'UserContextImpl@5e3ca754' will not be set since it is not a String and no Converter is available. Consider registering a Converter with ConversionService (e.g., <int:converter>)

    How do I do this please ? Can I use the ByteArrayHttpMessageConverter ?


    Thanks!
Working...
X