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 wi开发者_运维技巧th 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"
精彩评论