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'
答案 0 :(得分:2)
您无法使用
< int:default-header name="accountId" expression="payload.get('acccountId')"/>
创建消息时;消息(以及有效载荷)还没有存在。
您应该可以使用#args[0]['accountId']
。
评估没有#root
个对象。请参阅表达式和&#34;全球&#34;标题 here。