我試圖實現某種代理作爲我的數據流的一部分,我想接收一個http請求我的入站網關,並通過出站網關傳遞它。我想保留所有查詢字符串參數。我的網關的配置是:Spring集成,我怎麼能穿過站網關入站http請求?
<int:channel id="searchRequestChannel" />
<int:channel id="searchReplyChannel" />
<int-http:inbound-gateway id="searchRequestInboundGateway"
supported-methods="GET"
request-channel="searchRequestChannel"
reply-channel="searchReplyChannel"
path="/services/normalization"
reply-timeout="50000"
/>
<int-http:outbound-gateway id="searchServiceGateway"
http-method="GET"
request-channel="searchRequestChannel"
url="http://localhost:8080/query"
extract-request-payload="false"
expected-response-type="java.lang.String"
reply-timeout="50000"
charset="UTF-8"
/>
我預計它會工作如下:
客戶端發送請求到入站網關/服務/正常化:
GET /服務/歸一化q =貓&排除=黑
入站網關接收請求和searchRequestChannel發送通過到出站網關。
出站網關發送整個請求到外部服務:
GET /查詢q =貓&排除=黑色
但在實踐中,出站網關發送一個不包含任何空請求查詢參數:
GET /query
所以我的問題,什麼是送這是對入境gatew接受http請求最簡單的方法通過出站網關。換句話說,我如何通過彈簧集成工具實現簡單代理?
嗯。也許我做錯了,但收到的消息中的'queryString'頭是空的。我用HttpRequestExecutingMessageHandler.handleRequestMessage(Message >)方法在調試器中檢查了消息對象。和我的記錄器輸出https://gist.github.com/detsam/5538976 – masted 2013-05-08 08:15:23
對不起 - 我的錯誤 - 我用模擬HttpRequest測試它;讓我看看我是否可以提出另一項解決方案。 – 2013-05-08 13:03:39
我用一個需要Spring Integration 3.0的通用解決方案更新了我的答案,如果知道查詢參數,另一個解決方案將工作。 – 2013-05-08 15:08:04