HOWTOTRANSFORM JSONTO XML IN MULE
We have to use the json-to-xml-transformer to transform a json message to xml. I don't need any transformation of the data, simply turning the json properties into xml tags.
{ "root": { "name": “Mike", "fullname": “Muller", "address": “55 seventh street", "shipToZip": "16684", JSON Input :
"lineInfo": [ { "lineNumber": “523", "product": “FAT999" } ] } }
Output: <?xml version='1.0'?> <root> <name>Mike</name> <fullname>Muller</fullname> <address> 55 seventh street</address> <shipToZip>16684</shipToZip> <lineInfo> <lineNumber>523</lineNumber> <product>FAT999</product> </lineInfo> </root>
View of Flow: <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:json=http://www.mulesoft.org/schema/mule/json xmlns:http=http://www.mulesoft.org/schema/mule/http xmlns=http://www.mulesoft.org/schema/mule/core xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> <flow name="JsonToXmlTest" > <http:listener config-ref="HTTP_Listener_Configuration" path="/test" doc:name="HTTP"/> <json:json-to-xml mimeType="text/xml" doc:name="JSON to XML" ignoreBadInput="true"/> </flow> </mule>
Json to xml esb transformation

Json to xml esb transformation