codey_08
codey_08

Reputation: 249

transform the xml payload in mule 4 using dataweave 2.0

In my case, I've done the XML payload transform using Java in Mule 3.

But in Mule 4, could we be able to transform the xml payload using Dataweave 2.0.

I have an XML Request and Expected response payload. But I don't know to transform using Dataweave 2.0

Input XML: https://github.com/Manikandan99/demo/blob/master/input_xml_request

Output XML: https://github.com/Manikandan99/demo/blob/master/output_xml

Java code for my logic: https://github.com/Manikandan99/demo/blob/master/transform_xml.java

Note:

        * Difference between the input and output payload is that the value of the DTOStep node should be updated.
        * The attribute value of DTOStep is autoincremented from 500 each time.

Please assist me.

Upvotes: 1

Views: 874

Answers (1)

aled
aled

Reputation: 25837

In generic terms there are two main ways to resolve this in Mule 4.

  1. Implement the desired transformation in DataWeave 2. This is usually recommended and is the natural way in Mule 4.
  2. Migrate the Mule 3 Java code. This implies removing any references to Mule Java APIs, types, class, interfaces or packages from your Java code. Mule 4 expects plain Java code with not usage of Mule internals. For example that means no references to Mule events, messages nor variables. Just put everything as parameters of the methods you are calling and use the Java module. Don't assume Mule is magically sending DOM to your code. To invoke Java code in Mule 4 read the instructions in the documentations of the Java Module.

Upvotes: 2

Related Questions