0
我有Java對象,我想傳遞一個自定義標題,以我對HTTP站網關請求。下面是一個片段Spring集成 - HTTP站網關自定義頁眉
<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"/>
哪裏的UserContext可能是一個Java對象
UserContext implements Serializable {
String userId;
RequestParameters params;
ScopeEnum scope;
....
}
我的問題是,頭user_context沒有在頭映射。從日誌中,我可以看到DefaultHttpHeaderMapper正在請求Converter或ConversionService。見下 -
09:54:59,488 - WARN main org.springframework.integration.http.support.DefaultHttpHeaderMapper - Header 'X- user_context' with value '[email protected]' 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>)
我該怎麼做?
謝謝!