Mule ESB: DataWeave
xml input to Java Object example
This tutorial explains how to develop a
DataWeave transformation from XML to Java
Object.
Pre-requisite:
• Anypoint Studio 5.2.0
• Mule ESB Runtime 3.7.1
• xml input files.
Input XML File
<user>
<name>Annie</name>
<lastName>Point</lastName>
</user>
Mule Flow
Mule Source
<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 I 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
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

PPT
Spring introduction
PPTX
Mule jdbc
PPTX
Mule Esb Data Weave
ODP
Mule ESB SMTP Connector Integration
ODP
Box connector Mule ESB Integration
PPT
Anypoint connectorfor ibm as 400
PPTX
Quartz component in mule
PPTX
Mule esb :Data Weave
Spring introduction
Mule jdbc
Mule Esb Data Weave
Mule ESB SMTP Connector Integration
Box connector Mule ESB Integration
Anypoint connectorfor ibm as 400
Quartz component in mule
Mule esb :Data Weave

What's hot (12)

PPTX
For each component in mule
PDF
MuleSoft ESB Message Enricher
PPTX
Groovy example in mule
PPTX
Message properties component in Mule
ODP
Dropbox connector Mule ESB Integration
ODP
Running ms sql stored procedures in mule
PPTX
Send email attachment using smtp in mule esb
PPTX
Mule esb
PPTX
MuleSoft ESB scatter-gather and base64
PPTX
Junit in mule demo
PPTX
How to get http query parameters in mule
PPTX
Quartz component in mule demo
For each component in mule
MuleSoft ESB Message Enricher
Groovy example in mule
Message properties component in Mule
Dropbox connector Mule ESB Integration
Running ms sql stored procedures in mule
Send email attachment using smtp in mule esb
Mule esb
MuleSoft ESB scatter-gather and base64
Junit in mule demo
How to get http query parameters in mule
Quartz component in mule demo
Ad

Viewers also liked (13)

PPTX
Hi600 u13_inst_slides
PDF
Women participation in peace process
PPTX
Mapping and listing with mule
PDF
The mobile revolution is here: engaging our users where they are
PPTX
Instintos, Sexo y Sexualidad.
PPTX
cultivation practices of of peach
PPT
Procesos mentales
PPTX
02 baumgartner
PPT
10 cantin
PPT
Suppurative lung diseases
PPT
Macroestructura
PPTX
Mule with velocity
Hi600 u13_inst_slides
Women participation in peace process
Mapping and listing with mule
The mobile revolution is here: engaging our users where they are
Instintos, Sexo y Sexualidad.
cultivation practices of of peach
Procesos mentales
02 baumgartner
10 cantin
Suppurative lung diseases
Macroestructura
Mule with velocity
Ad

Similar to Mule esb Data Weave (20)

PPTX
Mule xml java
PPTX
Mule xml java
PPTX
Mulexml java
PPTX
Mule XML java sample
PPTX
Mulesoft xml to Java Conversion
PPTX
Mule xml parsing
PPTX
Mule xml parsing
PPTX
Caching invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching invalidating with managed store
PPTX
Caching and invalidating with managed store
 
PPTX
Caching and invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching and invalidating with managed store
PPTX
Caching & validating
ODP
Mule smtp connector
Mule xml java
Mule xml java
Mulexml java
Mule XML java sample
Mulesoft xml to Java Conversion
Mule xml parsing
Mule xml parsing
Caching invalidating with managed store
Caching and invalidating with managed store
Caching and invalidating with managed store
Caching invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed store
Caching and invalidating with managed store
Caching and invalidating with managed store
Caching and invalidating with managed store
Caching and invalidating with managed store
Caching & validating
Mule smtp connector

More from F K (20)

PPT
WebServices introduction in Mule
 
PPTX
Testing soapui
 
PPTX
Java For Begineers
 
PPTX
Vm component
 
PPTX
Until successful component in mule
 
PPTX
Quartz component
 
PPTX
Mule management console installation
 
PPTX
Mule esb made system integration easy
 
PPTX
Message properties component
 
PPTX
Junit in mule
 
PPTX
Install sonarqube plugin in anypoint
 
PPTX
Commit a project in svn using svn plugin in anypoint studio
 
PPTX
Github plugin setup in anypoint studio
 
PPTX
For each component
 
PPTX
Filter expression
 
PPTX
File component
 
PPTX
Database component
 
PPTX
Choice component
 
PPTX
Mule with drools
 
PPTX
Idempotent filter in Mule
 
WebServices introduction in Mule
 
Testing soapui
 
Java For Begineers
 
Vm component
 
Until successful component in mule
 
Quartz component
 
Mule management console installation
 
Mule esb made system integration easy
 
Message properties component
 
Junit in mule
 
Install sonarqube plugin in anypoint
 
Commit a project in svn using svn plugin in anypoint studio
 
Github plugin setup in anypoint studio
 
For each component
 
Filter expression
 
File component
 
Database component
 
Choice component
 
Mule with drools
 
Idempotent filter in Mule
 

Recently uploaded (20)

PDF
Comparative analysis of machine learning models for fake news detection in so...
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
Configure Apache Mutual Authentication
PDF
Advancing precision in air quality forecasting through machine learning integ...
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PPTX
Internet of Everything -Basic concepts details
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Comparative analysis of machine learning models for fake news detection in so...
Flame analysis and combustion estimation using large language and vision assi...
sbt 2.0: go big (Scala Days 2025 edition)
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
The influence of sentiment analysis in enhancing early warning system model f...
sustainability-14-14877-v2.pddhzftheheeeee
Configure Apache Mutual Authentication
Advancing precision in air quality forecasting through machine learning integ...
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
Internet of Everything -Basic concepts details
NewMind AI Weekly Chronicles – August ’25 Week IV
giants, standing on the shoulders of - by Daniel Stenberg
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
Taming the Chaos: How to Turn Unstructured Data into Decisions
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx

Mule esb Data Weave

  • 1. Mule ESB: DataWeave xml input to Java Object example
  • 2. This tutorial explains how to develop a DataWeave transformation from XML to Java Object. Pre-requisite: • Anypoint Studio 5.2.0 • Mule ESB Runtime 3.7.1 • xml input files. Input XML File <user> <name>Annie</name> <lastName>Point</lastName> </user>
  • 4. Mule Source <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 I 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; } }