JSON to XML in Mule 4
JSON to XML
is done via transform message component in mule 4
Flow:
Transform
message settings:
Method: POST
Input & output:
XML project
code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="4449acc5-2147-4b7f-9c8c-87d78010c2f5" >
<http:listener-connection host="0.0.0.0" port="8085" />
</http:listener-config>
<flow name="test_jsontoxmlFlow" doc:id="3dd3f384-2ec0-4218-985c-696ee4f2e67e" >
<http:listener doc:name="Listener" doc:id="389e3d73-7a5d-46c3-82e3-0ff7eedd839c" config-ref="HTTP_Listener_config" path="/transform"/>
<ee:transform doc:name="Transform Message" doc:id="64a2f267-1d02-4b81-8434-27ee3c4a50e6" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
data:payload
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>
</mule>
No comments:
Post a Comment