SlideShare a Scribd company logo
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
Transformation xmltoobjectesb
PPTX
Transformation xmltoobjectesb
PPTX
Transformation xmltoobjectesb
PPTX
Transformation xmltoobjectesb
PPTX
Muleesbobjecttojson
PPTX
Mule esb object_to_json
PPTX
Mule esb json_to_object
PPTX
Dataweave nagarjuna
PPTX
Data weave in Mule
PPTX
Dataweave by nagarjuna
PPTX
Transform Message
PPTX
Mule esb object_to_json
PDF
Data weave
Mule xml java
Mule xml java
Mulexml java
Mule XML java sample
Mulesoft xml to Java Conversion
Mule xml parsing
Mule xml parsing
Transformation xmltoobjectesb
Transformation xmltoobjectesb
Transformation xmltoobjectesb
Transformation xmltoobjectesb
Muleesbobjecttojson
Mule esb object_to_json
Mule esb json_to_object
Dataweave nagarjuna
Data weave in Mule
Dataweave by nagarjuna
Transform Message
Mule esb object_to_json
Data weave

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
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
A Presentation on Artificial Intelligence
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
KodekX | Application Modernization Development
PDF
Network Security Unit 5.pdf for BCA BBA.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
A Presentation on Artificial Intelligence
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
NewMind AI Monthly Chronicles - July 2025
KodekX | Application Modernization Development
Network Security Unit 5.pdf for BCA BBA.

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; } }