简体   繁体   中英

Mule ESB Create map payload

I need to transform inbound payload into map (java.util.Map). There are any way to create map in mule xml configs?

Regards

EDIT: Payload type is com.novell.LDAPAttributeSet which is set of LDAPAttribute objects. LDAPAttribute object contains name and value fields. I need to extract name and value fields and convert them to map. Extracting fields will done with jxpath expressions. But I don't know how to create map from these fields.

I suggest you use a Groovy transformer:

<script:transformer>
  <script:script engine="groovy">
    [key1: payload.attr1,
     key2: payload.attr2]
  </script:script>
</script:transformer>

Where key1,key2 are your choice of keys to use in the map and attr1,attr2 are attributes of the LDAPAttributeSet (or any other valid expression that allows you to get the desired values out of this object).

PS. In case you wonder, the script namespace is declared that way:

xmlns:script="http://www.mulesoft.org/schema/mule/scripting"

xsi:schemaLocation="
   http://www.mulesoft.org/schema/mule/scripting 
   http://www.mulesoft.org/schema/mule/scripting/3.1/mule-scripting.xsd"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM