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 Nagendra Kumar (7)

PPTX
Polling with watermark
PPTX
M unit testing example
PPTX
Mulesoft connector devkit
PPTX
Mule flatfile-json
PPTX
Cache scope
PPTX
Mule flatfile-json
PPTX
Mule copy book-tutorial
Polling with watermark
M unit testing example
Mulesoft connector devkit
Mule flatfile-json
Cache scope
Mule flatfile-json
Mule copy book-tutorial

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Electronic commerce courselecture one. Pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Building Integrated photovoltaic BIPV_UPV.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MYSQL Presentation for SQL database connectivity
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25 Week I
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.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; } }