【发布时间】:2015-12-19 23:53:04
【问题描述】:
RequestGateway.Java
public interface RequestGateway {
String echo(Map<String, String> request);
String echo(String request);
}
Test.java
Map<String, String> requestMap = new HashMap<String, String>();
requestMap.put("acccountId", "1111222233334444");
requestMap.put("currencyCode", "USD");
requestMap.put("paymentAmount", "100.00");
RequestGateway paymentRequestGateway = context.getBean("paymentRequestGateway", RequestGateway.class);
String availableCreditBalance = paymentRequestGateway.echo(requestMap);
SIConfig.xml
<int:gateway id="paymentRequestGateway"
service-interface="com.api.orchestration.api.RequestGateway"
default-request-channel="PaymentAuthRequestChannel"
default-reply-channel="ResponseChannel">
<int:default-header name="Accept" value="application/json; v=3"/>
<int:default-header name="Content-Type" value="application/json"/>
<int:default-header name="accountId" expression="payload.get('acccountId')"/>
</int:gateway>
<int-http:outbound-gateway
id="IG2 Outbound Gateway"
request-channel="IG2RequestChannel"
reply-channel="ResponseChannel"
header-mapper="headerMapper"
url-expression="'http://localhost:9090/balance/account/'+ headers['accountId']"
http-method="GET"
expected-response-type="java.lang.String">
</int-http:outbound-gateway>
如何将参数从 Java 代码传递给 url-expression,我可能对 default-header 中的表达式做错了什么?
这适用于 http:outbound-gateway 中的 url-expression
< int:default-header name="accountId" value="1111222233334444"/>
这不是..
< int:default-header name="accountId" expression="payload.get('acccountId')"/>
“错误:EL1007E:(pos 0): 在 null 上找不到属性或字段‘payload’”
【问题讨论】: