I am writing a Mule flow which expects xml as a input payload and returns xml output via http endpoint. I am performing some validation on the incoming xml and if it fails i want to return the same xml with some modification.
incoming xml:
<test>
<a>1</a>
<b>value1</b>
</test>
output xml:
<test>
<a>2</a>
<b>value2</b>
</test>
how can i update the xml values in Mule flow??
By far the easiest way to do this is to use JAXB, it is FAST in Mule, and then you can use java to access it.
Use This Tool to build your XML Schema
Use XJC to create a JAXB object out of it.
Then in Mule you would use a XML to JAXB Object transformer, Do whatever you want with it, and then send it out with an JAXB Object to XML transformer.