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

PPTX
Mule Esb Data Weave
PPTX
For each component in mule
PPTX
Quartz component in mule
ODP
Mule ESB SMTP Connector Integration
PPTX
Mule jdbc
PPTX
Message properties component in Mule
PPT
Spring introduction
PPTX
Groovy example in mule
Mule Esb Data Weave
For each component in mule
Quartz component in mule
Mule ESB SMTP Connector Integration
Mule jdbc
Message properties component in Mule
Spring introduction
Groovy example in mule

What's hot (12)

ODP
Box connector Mule ESB Integration
PPTX
Mule esb :Data Weave
PPTX
Until successful component in mule
PPTX
How to get http query parameters in mule
PPTX
Junit in mule demo
PPTX
Quartz component in mule demo
PPTX
Mule esb
PPTX
Mulesoft Using Groovy Component
PPTX
Expression filter in Mule
PPTX
MuleSoft ESB scatter-gather and base64
PPTX
Send email attachment using smtp in mule esb
ODP
Running ms sql stored procedures in mule
Box connector Mule ESB Integration
Mule esb :Data Weave
Until successful component in mule
How to get http query parameters in mule
Junit in mule demo
Quartz component in mule demo
Mule esb
Mulesoft Using Groovy Component
Expression filter in Mule
MuleSoft ESB scatter-gather and base64
Send email attachment using smtp in mule esb
Running ms sql stored procedures in mule
Ad

Similar to Mule esb DataWeave (20)

PPTX
Mule xml java
PPTX
Mule xml java
PPTX
Mule XML java sample
PPTX
Mulexml java
PPTX
Mulesoft xml to Java Conversion
PPTX
Mule xml parsing
PPTX
Mule xml parsing
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 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
Mule XML java sample
Mulexml java
Mulesoft xml to Java Conversion
Mule xml parsing
Mule xml parsing
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 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
Ad

More from Praneethchampion (20)

PPTX
How to use expression filter
PPT
Mule execution
PPTX
Mule soap
PPTX
PPTX
Mule esb stripe
PPT
Mule security-jaas
PPT
Mule batch processing
PPTX
Mmc rest api user groups
PPTX
Dataweave
PPTX
Mule for each scope header collection
PPTX
Mapping and listing with mule
PPT
Mule oracle connectors
PPT
Mule esb api layer
PPT
Anypoint data gateway
PPT
Mule google connectors
PPT
Mule anypoint exchange
PPT
Mule security
PPTX
Webservice vm in mule
PPTX
Soap request in mule
How to use expression filter
Mule execution
Mule soap
Mule esb stripe
Mule security-jaas
Mule batch processing
Mmc rest api user groups
Dataweave
Mule for each scope header collection
Mapping and listing with mule
Mule oracle connectors
Mule esb api layer
Anypoint data gateway
Mule google connectors
Mule anypoint exchange
Mule security
Webservice vm in mule
Soap request in mule

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
KodekX | Application Modernization Development
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.
The AUB Centre for AI in Media Proposal.docx
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Monthly Chronicles - July 2025
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KodekX | Application Modernization Development
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

Mule esb DataWeave

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