0
我需要通過Spring Integration的HTTP出站網關調用REST API。如何用有效載荷中的值替換路徑變量。 Payload只有一個字符串值。下面的代碼片段發送佔位符。任何幫助表示讚賞。HTTP出站網關 - 傳遞URI參數
@Bean
public MessageHandler httpGateway(@Value("http://localhost:8080/api/test-resource/v1/{parameter1}/codes") URI uri) {
HttpRequestExecutingMessageHandler httpHandler = new HttpRequestExecutingMessageHandler(uri);
httpHandler.setExpectedResponseType(Map.class);
httpHandler.setHttpMethod(HttpMethod.GET);
Map<String, Expression> uriVariableExp = new HashMap();
SpelExpressionParser parser = new SpelExpressionParser();
uriVariableExp.put("parameter1", parser.parseExpression("payload.Message"));
httpHandler.setUriVariableExpressions(uriVariableExp);
return httpHandler;
}
謝謝阿爾喬姆。現在工作正常。我已經將url移至application.properties並更新瞭如下所示的表達式uriVariableExp.put(「parameter1」,parser.parseExpression(「payload」)); – Sarath