我遇到了一种情况,即使用<int-http:outbound-channel-adapter ... />发送包含存储在标头中的信息的对象。
当我调用<int-http:inbound-channel-adapter ... />时,如下所示:
public void openTicket(final Profile profile, final Ticket ticket) {
final HttpHeaders headers = new HttpHeaders();
headers.set("profile", profile.toString());
final HttpEntity<Ticket> entity = new HttpEntity<Ticket>(ticket, headers);
template.exchange(URL, HttpMethod.PUT, entity, Ticket.class);
}这将调用我的内置通道适配器成功地在标头中使用给定的配置文件:
<int-http:inbound-channel-adapter
channel="api_app_integration_request_channel"
supported-methods="PUT"
path="/process/ticket"
request-payload-type="*.model.Ticket"
mapped-request-headers="profile"
error-channel="internal-client-rest-ticket-error-channel"
>
<int-http:request-mapping consumes="application/json" />
</int-http:inbound-channel-adapter>不起作用的是通过出站通道适配器调用服务,呼叫本身也能工作,但是我的头文件“配置文件”已经消失了。
<int-http:outbound-channel-adapter
channel="client_rest_ticket_outbound_channel"
http-method="PUT"
url="http://localhost:8080/process/ticket"
mapped-request-headers="profile"
/>我使用的是Spring-Boot1.3.6。
发布于 2016-07-18 07:22:23
默认情况下,(当前)用X-前缀映射自定义标头;要映射它们,需要将userDefinedHeaderPrefix设置为null (或"")的DefaultHttpHeaderMapper和要映射的出站标头名称连接起来。
见文献资料。
编辑:
<bean class="org.springframework.integration.http.support.DefaultHttpHeaderMapper" id="headerMapper"
p:userDefinedHeaderPrefix=""
p:inboundHeaderNames="profile"
p:outboundHeaderNames="profile"
/>https://stackoverflow.com/questions/38424637
复制相似问题