0
我正在使用標題值路由器,並且在最終的webservice中,用於標題值路由的標題附加了一個X- *字符串。Spring集成在用於標題值路由的標題中添加了X- *到自定義標題
Spring集成路由器片斷
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-http="http://www.springframework.org/schema/integration/http"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd">
<bean id="byteArrayHttpMessageConverter"
class="org.springframework.http.converter.ByteArrayHttpMessageConverter">
</bean>
<bean id="formHttpMessageConverter"
class="org.springframework.http.converter.FormHttpMessageConverter">
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
<bean id="headerMapper"
class="org.springframework.integration.http.support.DefaultHttpHeaderMapper">
<property name="inboundHeaderNames" value="*" />
<property name="outboundHeaderNames" value="*" />
<property name="userDefinedHeaderPrefix" value="" />
</bean>
<int:channel id="http.request.submit.withfiles" />
<int:channel id="http.response.submit.withfiles" />
<int:channel id="http.router.route1.process.submit.withfiles" />
<int:channel id="http.router.route2.process.submit.withfiles" />
<int-http:inbound-gateway id="http.gateway.inbound.submit.withfiles"
supported-methods="POST" header-mapper="headerMapper"
request-channel="http.request.submit.withfiles"
reply-channel="http.response.submit.withfiles" path="/v1.0/file">
<int-http:request-mapping consumes="multipart/form-data"
produces="application/json" />
<int-http:header name="routingCode" expression="headers['routingCode']" />
</int-http:inbound-gateway>
<int:header-value-router input-channel="http.request.submit.withfiles"
header-name="routingCode" default-output-
channel="http.router.route2.process.submit.withfiles">
<int:mapping value="AB"
channel="http.router.route1.process.submit.withfiles" />
<int:mapping value="AC"
channel="http.router.route2.process.submit.withfiles" />
</int:header-value-router>
<int-http:outbound-gateway
id="http.gateway.outbound.route1.submit.withfiles" header-mapper="headerMapper"
request-channel="http.router.route1.process.submit.withfiles"
reply-channel="http.response.submit.withfiles"
url="http://localhost:8080/myapplication1/file"
http-method-expression="headers.http_requestMethod"
expected-response-type="java.lang.String" charset="UTF-8"
reply-timeout="50000" />
拍攝的首部如下:
GET /mapfre-tron-mobile/badgeCounters HTTP/1.1
Accept: */*
X-*routingCode: AB
X-*http_requestMethod: GET
X-*errorChannel: org.springframewor[email protected]c52014
accept-language: en-US,en;q=0.8,ml;q=0.6
authorization: 43c3a826-eef1-42f7-af80-e017964ca158
X-*replyChannel: org.springframewor[email protected]c52014
X-*http_requestUrl: http://localhost:8080/my-switcher/v1.0/file
content-type: application/json
X-*id: 1b24823e-0d07-1225-aead-b80f3a8691b1
Cache-Control: no-cache
accept-encoding: gzip, deflate, sdch
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
X-*timestamp: 1443145971493
Pragma: no-cache
Host: localhost:8081
Connection: keep-alive
正如你所看到的,我傳遞routingCode作爲標題,但它成爲X- * routingCode :.
有什麼想法?
加里,感謝您的關注。如你所見,我更新了完整的路線xml。我只想提及,我傳遞了2個頭文件 - authorization和routeCode。這個問題只發生在用於標題值路由的路由代碼中,授權即將到來而沒有任何問題。 – user3121011
這並不明顯,我需要看到一個DEBUG日誌。但是,正如我所說的,在入站和出站HTTP適配器上映射所有頭文件'「*」'是非常不尋常的。在入站和出站網關上使用相同的映射器也是不尋常的。嘗試在出站網關上映射「HTTP_REQUEST_HEADERS,authorization,routeCode」。另外,看看DEBUG日誌並將其發佈到某個地方,如果無法弄清楚的話。 –
已解決。我有很多SI路由配置文件,它們被導入到一個文件中。在路徑文件中的一個,我不得不像的配置<豆ID = 「headerMapper」 \t \t類= 「org.springframework.integration.http.support.DefaultHttpHeaderMapper」> \t \t <屬性名= 「inboundHeaderNames」 值= 「*」/> \t \t <屬性名= 「outboundHeaderNames」 值= 「*」/> \t \t <屬性名= 「userDefinedHeaderPrefix」 值= 「X- *」/> \t。所以我將bean從headerMapper更改爲headerMapper1。 – user3121011