SlideShare a Scribd company logo
1 of 8
How to use DataWeave
component
14-05-2015
Abstract
• The main motto of this PPT is How to use
DataWeave in our applications.
Introduction
• The DataWeave language is a simple,
powerful tool to query and transform data
inside of Mule.
Example
.mflow
• <?xml version="1.0" encoding="UTF-8"?>
• <mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
• xmlns:spring="http://www.springframework.org/schema/beans"
• xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
• xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
• http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
• http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
• http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
• <flow name="dataweaveFlow">
• <file:inbound-endpoint path="D:csvcontact" responseTimeout="10000" doc:name="File"/>
• <logger message="flow started" level="INFO" doc:name="Logger"/>
• <dw:transform-message metadata:id="5e76ab87-23c8-4c36-9618-6620c53520f8" doc:name="Transform Message">
• <dw:set-payload><![CDATA[%dw 1.0
• %output application/json
• ---
• {
•
•
• Address: {
•
•
•
• Country: payload.Address.Country,
•
•
• State: payload.Address.State
• ,
•
• City: payload.Address.City
• }
• }]]></dw:set-payload>
• </dw:transform-message>
• <logger message="--Output--#[message.payloadAs(java.lang.String)]--" level="INFO" doc:name="Logger"/>
• </flow>
• </mule>
• Output:
• INFO 2016-05-06 12:38:07,038
[[dataweave].connector.file.mule.default.receiver.01]
org.mule.transport.file.FileMessageReceiver: Lock obtained on file:
D:csvcontactsample.xml
• INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05]
org.mule.api.processor.LoggerMessageProcessor: flow started
• INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05]
org.mule.api.processor.LoggerMessageProcessor: --Output--{
• "Address": {
• "Country": "India",
• "State": "AP",
• "City": "Dharmavaram"
• }
• }--
•
•
•
• Flow of execution:
1. The above flow is used to convert xml to JSON
using DataWeave
2. It will pick the .xml file from specific location and
will convert and display json response in console
3. Sample xml:
<Address>
<Country>India</Country>
<State>AP</State>
<City>Dharmavaram</City>
</Address>
References
• https://docs.mulesoft.com/mule-user-
guide/v/3.7/dataweave

More Related Content

What's hot (11)

How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
Data Mapper
Data MapperData Mapper
Data Mapper
 
Splitter
SplitterSplitter
Splitter
 
Message properties component in mule
Message properties component in muleMessage properties component in mule
Message properties component in mule
 
Wildcard Filter
Wildcard FilterWildcard Filter
Wildcard Filter
 
Defining global exception strategies
Defining global exception strategiesDefining global exception strategies
Defining global exception strategies
 
Collection aggregator
Collection aggregatorCollection aggregator
Collection aggregator
 
Validate json schema
Validate json schemaValidate json schema
Validate json schema
 
Reference exception strategy
Reference exception strategyReference exception strategy
Reference exception strategy
 
Expression filter in Mule
Expression filter in MuleExpression filter in Mule
Expression filter in Mule
 
How to use expression filter
How to use expression filter How to use expression filter
How to use expression filter
 

Viewers also liked

Integrate mule esb with microsoft office 365 share point
Integrate mule esb with microsoft office 365 share pointIntegrate mule esb with microsoft office 365 share point
Integrate mule esb with microsoft office 365 share pointsivachandra mandalapu
 
Specifying a default exception strategy
Specifying a default exception strategySpecifying a default exception strategy
Specifying a default exception strategysivachandra mandalapu
 
Integration with dropbox using mule esb
Integration with dropbox using mule esbIntegration with dropbox using mule esb
Integration with dropbox using mule esbsivachandra mandalapu
 

Viewers also liked (20)

Bean as Datasource
Bean as DatasourceBean as Datasource
Bean as Datasource
 
How to use IMAP endpoint
How to use IMAP endpointHow to use IMAP endpoint
How to use IMAP endpoint
 
Not Filter
Not FilterNot Filter
Not Filter
 
How to use jms outbound endpoint
How to use jms outbound endpointHow to use jms outbound endpoint
How to use jms outbound endpoint
 
Dockerizing mule soft esb
Dockerizing mule soft esbDockerizing mule soft esb
Dockerizing mule soft esb
 
How to use poll scope
How to use poll scopeHow to use poll scope
How to use poll scope
 
Cloud hub deployment
Cloud hub deploymentCloud hub deployment
Cloud hub deployment
 
Integrate mule esb with microsoft office 365 share point
Integrate mule esb with microsoft office 365 share pointIntegrate mule esb with microsoft office 365 share point
Integrate mule esb with microsoft office 365 share point
 
Securing api with_o_auth2
Securing api with_o_auth2Securing api with_o_auth2
Securing api with_o_auth2
 
How to use processor chain
How to use processor chainHow to use processor chain
How to use processor chain
 
How to use parse template
How to use parse templateHow to use parse template
How to use parse template
 
How to read json message payload
How to read json message payloadHow to read json message payload
How to read json message payload
 
How to use attachment transformer
How to use attachment transformerHow to use attachment transformer
How to use attachment transformer
 
How to use web service consumer
How to use web service consumerHow to use web service consumer
How to use web service consumer
 
How to use message enricher
How to use message enricherHow to use message enricher
How to use message enricher
 
Sap
SapSap
Sap
 
Specifying a default exception strategy
Specifying a default exception strategySpecifying a default exception strategy
Specifying a default exception strategy
 
Soap Component
Soap ComponentSoap Component
Soap Component
 
Mule esb with amazon s3 Integration
Mule esb with amazon s3 IntegrationMule esb with amazon s3 Integration
Mule esb with amazon s3 Integration
 
Integration with dropbox using mule esb
Integration with dropbox using mule esbIntegration with dropbox using mule esb
Integration with dropbox using mule esb
 

Similar to How to use data weave

How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentSunil Komarapu
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentAnand kalla
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentKhasim Saheb
 
Message properties component
Message properties component Message properties component
Message properties component Sunil Komarapu
 
Message properties component
Message properties componentMessage properties component
Message properties componentF K
 
How to use file component
How to use file componentHow to use file component
How to use file componentmaheshtheapex
 
Mule- File component example
Mule- File component exampleMule- File component example
Mule- File component exampleDivyaSree1391
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentprinceirfancivil
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentirfan1008
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties componentPhaniu
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filterSunil Komarapu
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filterAnand kalla
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filterKhasim Saheb
 
File component in mule
File component in muleFile component in mule
File component in mulejaveed_mhd
 

Similar to How to use data weave (20)

Mule Message Properties Component
Mule Message Properties ComponentMule Message Properties Component
Mule Message Properties Component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
Expression Filters
Expression FiltersExpression Filters
Expression Filters
 
Message properties component
Message properties component Message properties component
Message properties component
 
Message properties component
Message properties componentMessage properties component
Message properties component
 
How to use and filter
How to use and filterHow to use and filter
How to use and filter
 
How to use file component
How to use file componentHow to use file component
How to use file component
 
Mule- File component example
Mule- File component exampleMule- File component example
Mule- File component example
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
How to use or filter
How to use or filterHow to use or filter
How to use or filter
 
How to use not filter
How to use not filterHow to use not filter
How to use not filter
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
 
File component in mule
File component in muleFile component in mule
File component in mule
 
File component
File component File component
File component
 

More from sivachandra mandalapu (16)

Mock component in munit
Mock component in munitMock component in munit
Mock component in munit
 
Jms selector
Jms selectorJms selector
Jms selector
 
Sftplite
SftpliteSftplite
Sftplite
 
Object store
Object storeObject store
Object store
 
How to use SFTP
How to use SFTPHow to use SFTP
How to use SFTP
 
How to use secure property placeholder
How to use secure property placeholderHow to use secure property placeholder
How to use secure property placeholder
 
Validation
ValidationValidation
Validation
 
Property place holder
Property place holderProperty place holder
Property place holder
 
Deployment options for mule applications
Deployment options for mule applicationsDeployment options for mule applications
Deployment options for mule applications
 
Setting up organization with api access
Setting up organization with api accessSetting up organization with api access
Setting up organization with api access
 
API gateway setup
API gateway setupAPI gateway setup
API gateway setup
 
Expression
ExpressionExpression
Expression
 
Synchronous communication using jms back channel
Synchronous communication using jms back channelSynchronous communication using jms back channel
Synchronous communication using jms back channel
 
Salesforce
SalesforceSalesforce
Salesforce
 
Rest Component
Rest ComponentRest Component
Rest Component
 
Integration of mule esb with microsoft azure
Integration of mule esb with microsoft azureIntegration of mule esb with microsoft azure
Integration of mule esb with microsoft azure
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

How to use data weave

  • 1. How to use DataWeave component 14-05-2015
  • 2. Abstract • The main motto of this PPT is How to use DataWeave in our applications.
  • 3. Introduction • The DataWeave language is a simple, powerful tool to query and transform data inside of Mule.
  • 5. .mflow • <?xml version="1.0" encoding="UTF-8"?> • <mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" • xmlns:spring="http://www.springframework.org/schema/beans" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" • xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd • http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd • http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd • http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd"> • <flow name="dataweaveFlow"> • <file:inbound-endpoint path="D:csvcontact" responseTimeout="10000" doc:name="File"/> • <logger message="flow started" level="INFO" doc:name="Logger"/> • <dw:transform-message metadata:id="5e76ab87-23c8-4c36-9618-6620c53520f8" doc:name="Transform Message"> • <dw:set-payload><![CDATA[%dw 1.0 • %output application/json • --- • { • • • Address: { • • • • Country: payload.Address.Country, • • • State: payload.Address.State • , • • City: payload.Address.City • } • }]]></dw:set-payload> • </dw:transform-message> • <logger message="--Output--#[message.payloadAs(java.lang.String)]--" level="INFO" doc:name="Logger"/> • </flow> • </mule>
  • 6. • Output: • INFO 2016-05-06 12:38:07,038 [[dataweave].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: D:csvcontactsample.xml • INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05] org.mule.api.processor.LoggerMessageProcessor: flow started • INFO 2016-05-06 12:38:07,038 [[dataweave].dataweaveFlow.stage1.05] org.mule.api.processor.LoggerMessageProcessor: --Output--{ • "Address": { • "Country": "India", • "State": "AP", • "City": "Dharmavaram" • } • }-- • • •
  • 7. • Flow of execution: 1. The above flow is used to convert xml to JSON using DataWeave 2. It will pick the .xml file from specific location and will convert and display json response in console 3. Sample xml: <Address> <Country>India</Country> <State>AP</State> <City>Dharmavaram</City> </Address>