I’m trying to call a stored procedure on a MySQL DB, but my MEL expression is not working. I’ve referenced - https://docs.mulesoft.com/mule-user-guide/v/3.7/json-module-reference
My setup
**********************************************************************
* Mule Runtime and Integration Platform *
* Version: 3.8.0 Build: 9461215f *
* MuleSoft, Inc. *
* For more information go to *
* http://www.mulesoft.com/mule-esb-enterprise *
* *
* Server started: 8/31/16 11:23 AM *
* JDK: 1.8.0_91 (mixed mode) *
* OS: Mac OS X (10.11.6, x86_64) *
* Host: AMAC02PF791G3QC (10.13.164.24) *
**********************************************************************
The Error
Message : Execution of the expression "message.payload.lines[0].SKU" failed. (org.mule.api.expression.ExpressionRuntimeException).
Payload : {
"po_id": 1234,
"lines": [
{
"SKU": "1000",
"Primary SSA": "990471-Franjo",
"pre_pro": 1,
"pre_pro_need_by": "01/01/2016",
"top": 0,
"top_need_by": "01/01/2016",
"sample_size:": "small"
},
{
"SKU": "1000",
"Primary SSA": "990471-Franjo",
"pre_pro": 1,
"pre_pro_need_by": "01/01/2016",
"top": 0,
"top_need_by": "01/01/2016",
"sample_size:": "small"
}
]
}
Payload Type : java.lang.String
Element : /post:\/samples:application\/json:api-config/processors/0 @ r-exp-1.3:api.xml:193
Element XML : <db:stored-procedure config-ref="MySQL_Configuration" doc:name="Create Samples">
<db:parameterized-query>call P_CREATE_SAMPLE_WRAP (@requestID,:primarySsa,:purchaseOrderId,:sku1,:sampleSize,:sampleColors,:createdBy,:lastUpdatedBy,:preProNeedBy,:preProType,:topNeedBy,:topType);</db:parameterized-query>
<db:in-param name="primarySsa" type="VARCHAR" value="'990471'"></db:in-param>
<db:in-param name="purchaseOrderId" type="INTEGER" value="#[message.payload.po_id]"></db:in-param>
<db:in-param name="sku1" type="INTEGER" value="#[message.payload.lines[0].SKU]"></db:in-param>
<db:in-param name="sampleSize" type="VARCHAR" value="#[message.payload.lines[0].sample_size]"></db:in-param>
<db:in-param name="sampleColors" type="VARCHAR" value="null"></db:in-param>
<db:in-param name="lastUpdatedBy" type="VARCHAR" value="null"></db:in-param>
<db:in-param name="createdBy" type="VARCHAR" value="null"></db:in-param>
<db:in-param name="preProNeedBy" type="DATE" value="#[message.payload.lines[0].pre_pro_need_by]"></db:in-param>
<db:in-param name="preProType" type="VARCHAR" value="null"></db:in-param>
<db:in-param name="topNeedBy" type="DATE" value="#[message.payload.lines[0].top_need_by]"></db:in-param>
<db:in-param name="topType" type="VARCHAR" value="null"></db:in-param>
<db:out-param name="requestID" type="INTEGER"></db:out-param>
</db:stored-procedure>I’ve also tried this expression with the same payload
I’ve also tried
Message : Execution of the expression "message.payload.lines[0]/SKU" failed. (org.mule.api.expression.ExpressionRuntimeException).
I’ve only been using mulesoft for 2 weeks so any advice is greatly appreciated. Thanks!
答案 0 :(得分:1)
发生错误是因为有效负载是String形式,并且无法执行message.payload.lines[0]/SKU
。
由于邮件格式是JSON,因此您可以尝试将其替换为json:lines[0]/SKU
答案 1 :(得分:1)
您的有效负载是String类型。将其转换为json或java对象,然后您可以使用相同的方式访问它。
答案 2 :(得分:0)
[dw('message.payload.lines[0].SKU')]