如何提取从JDBC响应(通过MEL)Mule ESB返回的resultSet的值 [英] How to Extract the value of resultSet returned from JDBC response (Via MEL) Mule ESB

查看:219
本文介绍了如何提取从JDBC响应(通过MEL)Mule ESB返回的resultSet的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JDBC中调用存储过程,它返回如下响应,但是我不确定如何提取结果集的值

I have JDBC where I'm calling the stored Procedure, It is returning the response as below, But I'm pretty not sure how to extract the value of result set

请找到数据库的回复

{updateCount1=4,resultSet1=[{XML_F5RYI-11YTR=<Customers><Customer1>John<Customer1><Customer2>Ganesh<Customer2><Customers>}],resultSet2[{SequenceNumber=94}],updateCount2=1, updateCount3=4}

我已经使用了这个表达式#[message.payload.get(0)],它已经返回了ResultSet,如下所示,但不是完全需要的值.我需要使用XML_F5RYI-11YTR的xml值.

I have used the this expression #[message.payload.get(0)], It has return the ResultSet as below, But not exactly value required. I need to take the xml value of XML_F5RYI-11YTR.

{XML_F5RYI-11YTR=<Customers><Customer1>John<Customer1><Customer2>Ganesh<Customer2><Customers>}

也尝试如下 #[message.payload.get(0).XML_F5RYI-11YTR],但出现错误,无法提取xml.

Also tried like below #[message.payload.get(0).XML_F5RYI-11YTR] but getting error , not able to extract the xml.

您能否建议我如何从ResultSet1中提取xml

Could you please suggest how can I extract the xml from the ResultSet1

推荐答案

在大多数情况下,您的工作方式应该可以工作.我认为这里发生的是列名称中的连字符被MEL解析器解释为减法.因此,您可以将其更改为此语法,并且它应该可以工作:

In most cases, the way you did it should work. I think what is happening here is that the hyphen in the column name is interpreted by the MEL parser as a subtraction. So you could change yours to this syntax, and it should work:

#[message.payload.get(0)['XML_F5RYI-11YTR']]

您也可以省略消息",因为可以直接解析有效载荷:

Also you can omit "message", as payload is resolvable directly:

#[payload.get(0)['XML_F5RYI-11YTR']]

您可以使用数组括号语法而不是get方法来访问结果集中的第一行:

You could use array bracket syntax to access the first row in the result set, instead of the get method:

#[payload[0]['XML_F5RYI-11YTR']]

最后,您可能想对数据库返回的每一行进行一些操作.如果您使用集合分割器或for-each,则您的有效负载将是代表该行的地图,而不是代表整个结果集的地图列表:

Finally, you might want to do something for each row returned from the database. If you use a collection-splitter or a for-each, your payload will be the map that represents the row, instead of a list of maps representing the whole result set:

<collection-splitter />
<logger message="#[payload['XML_F5RYI-11YTR']]" />

编辑

要访问问题中显示的有效负载中的结果集,您将需要像这样访问它:

To access the result set in the payload shown in the question, you would need to access it like so:

#[payload.resultSet1[0]['XML_F5RYI-11YTR']]

这篇关于如何提取从JDBC响应(通过MEL)Mule ESB返回的resultSet的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆