Question

I know that I can use xslt to transform xml, but it costs a lot. I would like to know whether it is possible using grovvy or not. Assume I have two xml schema, and transfer them into java file, build to class and deploy to esb. And I transfer xml via groovy so that I can dynamically change the mapping without deployment java code.

Was it helpful?

Solution 2

This is a Groovy sample I wrote using WSO2 ESB Script mediator. This is for Json payload. However you can do the same for XML. Get payload using mc.getPayloadXML() method and use Groovy XmlSlurper class to parse xml to Groovy objects.

OTHER TIPS

WSO2 ESB supports Mediators implemented in a variety of scripting languages such as JavaScript, Groovy. (https://docs.wso2.org/display/ESB481/Script+Mediator)

To execute a Groovy script using the WSO2 ESB's script mediator follow below tutorial

http://heshans.blogspot.com/2011/05/executing-groovy-scripts-using-wso2-esb.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top