SlideShare a Scribd company logo
Data Weave Transformation
of MuleSoft ESB via
AnyPointStudio
 Transformation from XML
to Java
Transformation Flow
We need to transform from XML to Java with the help of Data weave
Language
Required things:
 Anypoint Studio
 xml input file.
 Mule ESB Runtime 3.7
Sample I/P XML file
<user>
<name>Srikanth</name>
<lastName>vlr</lastName>
</user>
Data transformation flow in
Anypointstudio
XML configuration file i.e. config.xml
<http:listener-config name="HTTP_Listener_Configuration"
host="0.0.0.0" port="8081" doc:name="HTTP Listener
Configuration"/>
<flow name="testweaveFlow">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/" metadata:id="cab0526f-779e-427c-9a33-be44f9b12696"
doc:name="HTTP"/>
<dw:transform-message doc:name="Transform Message">
<dw:input-payload doc:sample="json.json"/>
<dw:set-payload><![CDATA[%dw 1.0
%type user = :object { class: "testweave.User" }
%output application/java
---
{
firstName: payload.user.name,
lastName: payload.user.lastName
} as :user]]></dw:set-payload>
</dw:transform-message>
<byte-array-to-string-transformer doc:name="Byte Array to
String"/>
</flow>
In the transform code we have created the Object type
in the header
“ %type user = :object { class: "testweave.User"} ”
And the payload of the transform is converted to User
Object using the transform logic as below.
{
firstName: payload.user.name,
lastName: payload.user.lastName
} as :user
Transformation-DataWeave
User.java
package testweave;
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.firstName+" "+this.lastName;
}
}

More Related Content

PDF
Kubota B2050, B2350, B2650, B3150 Service Manual
PPTX
Mule xml java
PPTX
Mule xml java
PPTX
Mule esb DataWeave
PPTX
Mule esb dataweave
PPTX
Mule esb Data Weave
 
PPTX
Mule esb:DataWeave
PPTX
Mule esb
Kubota B2050, B2350, B2650, B3150 Service Manual
Mule xml java
Mule xml java
Mule esb DataWeave
Mule esb dataweave
Mule esb Data Weave
 
Mule esb:DataWeave
Mule esb

Similar to Mulesoft xml to Java Conversion (20)

PPTX
Mule esb
PPTX
Mule esb
PPTX
Mule esb
PPTX
Mule esb :Data Weave
PPTX
Mule esb
PPTX
Mule esb :Data Weave
PPTX
Mulexml java
PPTX
Mule XML java sample
PPTX
Mule Esb Data Weave
PPTX
Mule xml parsing
PPTX
Mule xml parsing
PPTX
Dataweave nagarjuna
PDF
Data weave
PPTX
Data weave in Mule
PPTX
Dataweave
PPTX
Data weave
PPTX
Data weave
PPTX
Data weave
PPTX
Data weave
PPTX
Dataweave by nagarjuna
Mule esb
Mule esb
Mule esb
Mule esb :Data Weave
Mule esb
Mule esb :Data Weave
Mulexml java
Mule XML java sample
Mule Esb Data Weave
Mule xml parsing
Mule xml parsing
Dataweave nagarjuna
Data weave
Data weave in Mule
Dataweave
Data weave
Data weave
Data weave
Data weave
Dataweave by nagarjuna
Ad

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
Teaching material agriculture food technology
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
Unlocking AI with Model Context Protocol (MCP)
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
Understanding_Digital_Forensics_Presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Teaching material agriculture food technology
MYSQL Presentation for SQL database connectivity
Programs and apps: productivity, graphics, security and other tools
sap open course for s4hana steps from ECC to s4
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Ad

Mulesoft xml to Java Conversion

  • 1. Data Weave Transformation of MuleSoft ESB via AnyPointStudio  Transformation from XML to Java Transformation Flow
  • 2. We need to transform from XML to Java with the help of Data weave Language Required things:  Anypoint Studio  xml input file.  Mule ESB Runtime 3.7 Sample I/P XML file <user> <name>Srikanth</name> <lastName>vlr</lastName> </user>
  • 3. Data transformation flow in Anypointstudio
  • 4. XML configuration file i.e. config.xml <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/> <flow name="testweaveFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/" metadata:id="cab0526f-779e-427c-9a33-be44f9b12696" doc:name="HTTP"/> <dw:transform-message doc:name="Transform Message"> <dw:input-payload doc:sample="json.json"/> <dw:set-payload><![CDATA[%dw 1.0 %type user = :object { class: "testweave.User" } %output application/java --- { firstName: payload.user.name, lastName: payload.user.lastName } as :user]]></dw:set-payload> </dw:transform-message> <byte-array-to-string-transformer doc:name="Byte Array to String"/> </flow>
  • 5. In the transform code we have created the Object type in the header “ %type user = :object { class: "testweave.User"} ” And the payload of the transform is converted to User Object using the transform logic as below. { firstName: payload.user.name, lastName: payload.user.lastName } as :user
  • 7. User.java package testweave; public class User { private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Override public String toString() { // TODO Auto-generated method stub return this.firstName+" "+this.lastName; } }