gpt4 book ai didi

mule - 使用 MEL 将 Map 设置为 Mule Flow 中的有效负载

转载 作者:行者123 更新时间:2023-12-05 01:16:28 26 4
gpt4 key购买 nike

我正在尝试动态生成并设置一个映射(具有 2 个键值对)作为以下 HTTP 调用的有效负载。但是,用于创建 map 的 MEL 表达式不起作用。

<sub-flow name="call-myservice" doc:name="call-myservice">
<set-payload value="#[username :${my.username}, password : ${my.password}]" doc:name="Set Payload"/>
<https:outbound-endpoint exchange-pattern="request-response" host="${myservice.Host}" method="POST" mimeType="application/json" doc:name="My Service call" path="mypath" port="443"/>
</sub-flow>

我按照 http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+MEL 中的说明进行操作

这表明——

MEL provides a streamlined way to access map data. 

Rather than constructing a map with a new statement, and then using its put method to populate it, you can simply write the following:

[key1 : value1, key2 : value2, . . .]

但是,它给了我以下异常 --

ERROR 2014-02-28 15:27:51,424 [[services-proxy].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message : Execution of the expression "username :abc, password : pwd" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. [Error: unresolvable property or identifier: username]
[Near : {... username :abc, pa ....}]
^
[Line: 1, Column: 1] (org.mvel2.PropertyAccessException)
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:687 (null)

最佳答案

您缺少用于分隔 map 的方括号(唯一用于分隔 Mule 表达式的方括号)。将其更改为:

<set-payload value="#[['username' :${my.username}, 'password' : ${my.password}]]" doc:name="Set Payload"/>

关于mule - 使用 MEL 将 Map 设置为 Mule Flow 中的有效负载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22106335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com