SlideShare a Scribd company logo
Mule ESB: Data Weave
XML – Java Conversion
XML – Java Conversion in Dataweave Mule
Pre-requisites:
 Anypoint Studio
 Mule ESB Runtime 3.7
 xml input file.
Input XML File
<user>
<name>Max</name>
<lastName>Mule</lastName>
</user>
Mule Flow
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 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;
}
}
Thank Q

More Related Content

PPTX
Mule XML java sample
PPTX
Mulexml java
PPTX
Mule xml parsing
PPTX
Mule xml parsing
ODP
Running ms sql stored procedures in mule
PPTX
Caching and invalidating with managed store
 
PPTX
Caching and invalidating with managed store
PPTX
Mulesoft xml to Java Conversion
Mule XML java sample
Mulexml java
Mule xml parsing
Mule xml parsing
Running ms sql stored procedures in mule
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Mulesoft xml to Java Conversion

What's hot (8)

PPT
Spring introduction
ODP
Mule ESB SMTP Connector Integration
PPTX
How to get http query parameters in mule
ODP
Box connector Mule ESB Integration
PPTX
Mule Esb Data Weave
PPTX
Caching & validating
PPTX
Mule esb data weave multi input data
PPTX
Mule esb :Data Weave
Spring introduction
Mule ESB SMTP Connector Integration
How to get http query parameters in mule
Box connector Mule ESB Integration
Mule Esb Data Weave
Caching & validating
Mule esb data weave multi input data
Mule esb :Data Weave
Ad

Similar to Mule xml java (20)

PPTX
Mule esb Data Weave
 
PPTX
Mule esb
PPTX
Mule esb:DataWeave
PPTX
Mule esb dataweave
PPTX
Mule esb :Data Weave
PPTX
Mule esb
PPTX
Mule esb
PPTX
Mule esb DataWeave
PPTX
Mule esb
PPTX
Mule esb
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
ODP
Mule smtp connector
Mule esb Data Weave
 
Mule esb
Mule esb:DataWeave
Mule esb dataweave
Mule esb :Data Weave
Mule esb
Mule esb
Mule esb DataWeave
Mule esb
Mule esb
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
Mule smtp connector
Ad

More from VirtusaPolaris (9)

PPTX
Mule m unit
PPTX
Mule debugging
PPTX
Mule connectors-part 1
PPTX
Mule error handling
PPTX
Mule core concepts
PPTX
Mule basics
PPTX
Mule flatfile-json
PPTX
Mule copy book-tutorial
PPTX
Mule ESB - Demo
Mule m unit
Mule debugging
Mule connectors-part 1
Mule error handling
Mule core concepts
Mule basics
Mule flatfile-json
Mule copy book-tutorial
Mule ESB - Demo

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
sap open course for s4hana steps from ECC to s4
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25-Week II
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
Assigned Numbers - 2025 - Bluetooth® Document
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.
Programs and apps: productivity, graphics, security and other tools
Reach Out and Touch Someone: Haptics and Empathic Computing
Per capita expenditure prediction using model stacking based on satellite ima...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

Mule xml java

  • 1. Mule ESB: Data Weave XML – Java Conversion
  • 2. XML – Java Conversion in Dataweave Mule Pre-requisites:  Anypoint Studio  Mule ESB Runtime 3.7  xml input file. Input XML File <user> <name>Max</name> <lastName>Mule</lastName> </user>
  • 4. 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 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; } }