1

我尝试访问来自 DataWeave 的 xml 下的元素。它给我返回空值。

DataWeave 脚本是

%dw 1.0
%namespace ns0 urn:abc:dbc:Components
%output text/xml
---
ItemFee:{
    product_id:flowVars."Dept_id",
    TotalFees: sum payload.ns0#ItemResponse.ns0#Fees.*ns0#Fee.ns0#Fee
}

在此数据编织之后,我立即拥有带有以下消息的记录器节点。

#[message.payload.ItemFee.TotalFees]

我收到错误消息

Execution of the expression "message.payload.ItemFee.TotalFees" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: WeaveMessageProcessor$WeaveOutputHandler

我想在这里多说一点。当我在“转换消息”之后立即在记录器中给出以下文本时。在控制台中打印的消息没有问题。但我无法访问 xml 消息中的元素。#[message.payloadAs(java.lang.String)]

4

2 回答 2

3

该 MEL 语法仅适用于 Java 对象。由于输出是 XML,您必须使用xpath3MEL 函数: https ://docs.mulesoft.com/mule-user-guide/v/3.7/xpath#the-xpath3-function

就像是:

#[xpath3('//ItemFee/TotalFees').text]
于 2015-12-18T20:19:47.300 回答
0

谢谢瑞恩。你的回答帮助了我。我在我的记录器中输入了下面的内容。然后我就可以拿东西了。

#[xpath3('//ItemFee/TotalFees')]

早些时候我尝试过这些东西,我不确定为什么它不能更早地工作。可能是我忽略了这个问题。:)

于 2015-12-18T23:19:23.887 回答