SlideShare a Scribd company logo
DATAWEAVE IN MULE
Using the DataWeave Transformer
• In Anypoint Studio, you can place a Transform
Message element in a flow to create transformations
using the DataWeave language.
• The editor helps you do this by offering intelligent
autocomplete suggestions, an output preview that is
updated in real time as you make changes.
• This generates a .dwl transformation file (or several of
them) that stores your code and is packaged with your
Mule application.
• When adding a Transform Message element to a Mule
Flow, it takes the elements from the incoming Mule
Message as its inputs. It then performs the necessary
actions to produce a Mule message as output for the next
element in the flow
• The DataWeave Text Editor GUI
• The Transform Message element allows you to freely
write DataWeave code.
• If you click on an instance of the Transform Message
element in your flow, its properties editor will be displayed.
This editor is divided into three sections:
• Input
• Transform
• Output
Input Section
In the main tab, a tree view shows the known metadata
contents of the incoming Mule Message, allowing you to
explore it and know what data is available for using as an
input, and how to reference each part of it.
If the Mule flow doesn’t expose Metadata about the
elements you need from the incoming message, you can
manually specify it. To do so, select the element of the input
you desire to define, note that the pencil icon at the top
right is no longer grayed out. Click this icon to open a new
tab in your input section where you can define a sample
with the structure of this data.
When the input is of JSON or XML types, the sample input contains plain XML or
JSON code. When the input is of type POJO or DataWeave, the sample input is
written in DataWeave for more simplicity. In these cases the sample DataWeave code
is merely a way to display the sample data, not a transformation in itself.
Setting Reader Parameters
• Some input formats, like CSV, allow you to define
a reader with specific properties that make
DataWeave parse inputs differently. Select the
input element you wish to configure on the tree
view of the input section, then click the gear icon.
Transform Section
• you write the actual DataWeave code that carries out the
transform. Notice that changing the type of your output
directive changes the output section of the editor.
Although DataWeave as a language supports adding
input directives and naming these by any name you like,
in Studio the elements of the input message are implicitly
considered input directives and so they don’t need to be
defined in the header.
If Studio has any metadata about the components that are
upstream or downstream from your Transform Message
element at the time when you add the component to your
flow, a scaffolding for your DataWeave code is written out
automatically, with as much depth as Studio can
intelligently deduce. In some cases, this code may be
enough to carry out the transformation you need, and no
additional coding is needed. Sometimes, all you need to do
is fill in the blank spaces in the scaffolding with references
to the input fields, other times you may want to carry out
more complex operations that involve aggregation, filtering,
calculations, defining custom functions, etc and there you
must write this out in DataWeave code.
Re-scaffolding
• Once you’ve added the Transform Message element to
your flow, any further changes you make to the
surrounding message processors and their metadata
won’t affect your `.dw`l file. You may still click the
Scaffolding button on the top left of the DataWeave
properties editor any time you want and have a new
scaffolding built, note that this will erase anything you’ve
written in the DataWeave body. Doing this won’t affect
any directives you defined in your header (except for the
output directive). Use this button if you’ve made any
changes to elements that come after the Transform
Message element on the flow that expose metadata and
don’t mind loosing what you’ve already written into the
transform’s body.
Referencing Existing Transforms
Instead of defining a new .dwl file, you can reference an
existing one by clicking theData Source button,
selecting On File as the source and referencing the correct
file.
Handling Multiple Outputs
A single Transform Message element can give shape to
several different components of the output Mule message.
Each of these output components must be defined in a
separate .dwl file, written out in a separate tab of the
Transform section. For example in one tab you may be
defining the payload contents, in another those of an
outbound property, and these will both be parts of the same
output Mule message
To add a new output, click the Plus sign at the
bottom right of the section:new+output.png[image]
A new tab will then appear, there you can specify
where in the output Mule message to place the
output of this DataWeave transform. In case you’re
creating a new variable or property, you must also
set a name for it.
In the XML editor you can do the same by adding multiple
child elements inside thedw:transform-message component.
<dw:transform-message>
<dw:set-payload resource="classpath:path/transform.dwl"/> <dw:set-
variable variableName="myVariable"
resource="classpath:path/transform.dwl"/> <dw:set-session-variable
variableName="mySessionVariable"
resource="classpath:path/transform.dwl"/> </dw:transform-message>
Output Section
• This section has two tabs, one of them shows you a neat
expandable tree view of the output data structure, the other
shows you a preview of what the actual output looks like, built
from any sample data you provide in the input section. As you
make changes in the transport section, notice how the data
structure changes. The output of the transformer is made into
the selected component of the output mule message. If your
transformer has multiple outputs, the Preview tab will display
the one corresponding to the currently selected transform.
Using DataWeave Language Elsewhere
• All components in Mule that support Mule Expression
Language also support expressions written in DataWeave
Language. To invoke an expression written in DataWeave
language, simply invoke the dw() function, the expression will
return whatever the transform outputs.
• DataWeave expressions defined within this function work just
as those defined within a Transform Message element, the only
difference is that the output is returned into the expression’s
result, wherever it may be.
• For example, you can define a custom object and
populate it with elements from the payload:
• That same expression could be added inside a Logger,
• within a MEL expression, to print out its result:
dw(myobject:{id:payload.accountid, user:payload.user})
#[`dw(myobject:{id:payload.accountid, user:payload.user})`]

More Related Content

What's hot

Mule Message Chunk Splitter
Mule Message Chunk SplitterMule Message Chunk Splitter
Mule Message Chunk Splitter
Ankush Sharma
 
Mule velocity
Mule velocityMule velocity
Mule velocity
Praneethchampion
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
Son Nguyen
 
Integration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESBIntegration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESB
Rupesh Sinha
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
AnilKumar Etagowni
 
Mule esb file to-string flow
Mule esb file to-string flowMule esb file to-string flow
Mule esb file to-string flow
Davide Rapacciuolo
 
File component in mule
File component in muleFile component in mule
File component in mule
Rajkattamuri
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
Praneethchampion
 
Mule agent notifications
Mule agent notificationsMule agent notifications
Mule agent notifications
Shanky Gupta
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interface
krishananth
 
Introduction to testing mule
Introduction to testing muleIntroduction to testing mule
Introduction to testing mule
Ramakrishna kapa
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
Praneethchampion
 
Velocity in Mule
Velocity in MuleVelocity in Mule
Velocity in Mule
Mohammed246
 
Mule advanced
Mule advancedMule advanced
Mule advanced
D.Rajesh Kumar
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Rajkattamuri
 
Dynamic file attribute
Dynamic file attributeDynamic file attribute
Dynamic file attribute
Anirban Sen Chowdhary
 
Introduction to dataweave
Introduction to dataweaveIntroduction to dataweave
Introduction to dataweave
Swati Deshpande
 
Creating restful api using mule esb
Creating restful api using mule esbCreating restful api using mule esb
Creating restful api using mule esb
RaviShankar Mishra
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
F K
 

What's hot (19)

Mule Message Chunk Splitter
Mule Message Chunk SplitterMule Message Chunk Splitter
Mule Message Chunk Splitter
 
Mule velocity
Mule velocityMule velocity
Mule velocity
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
 
Integration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESBIntegration with Dropbox using Mule ESB
Integration with Dropbox using Mule ESB
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 
Mule esb file to-string flow
Mule esb file to-string flowMule esb file to-string flow
Mule esb file to-string flow
 
File component in mule
File component in muleFile component in mule
File component in mule
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
 
Mule agent notifications
Mule agent notificationsMule agent notifications
Mule agent notifications
 
Mule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce InterfaceMule ESB - Mock Salesforce Interface
Mule ESB - Mock Salesforce Interface
 
Introduction to testing mule
Introduction to testing muleIntroduction to testing mule
Introduction to testing mule
 
Send email attachment using smtp in mule esb
Send email attachment using smtp in mule esbSend email attachment using smtp in mule esb
Send email attachment using smtp in mule esb
 
Velocity in Mule
Velocity in MuleVelocity in Mule
Velocity in Mule
 
Mule advanced
Mule advancedMule advanced
Mule advanced
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Dynamic file attribute
Dynamic file attributeDynamic file attribute
Dynamic file attribute
 
Introduction to dataweave
Introduction to dataweaveIntroduction to dataweave
Introduction to dataweave
 
Creating restful api using mule esb
Creating restful api using mule esbCreating restful api using mule esb
Creating restful api using mule esb
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
 

Viewers also liked

Mule drools
Mule drools Mule drools
Mule drools
Praneethchampion
 
Mule technology
Mule technologyMule technology
Mule technology
Praneethchampion
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
Praneethchampion
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
Praneethchampion
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
Praneethchampion
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
Praneethchampion
 
Damaging damzelz' no.1
Damaging damzelz' no.1Damaging damzelz' no.1
Damaging damzelz' no.1
tailgunnerx1
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
Praneethchampion
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
Praneethchampion
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
Praneethchampion
 
Mule security-jaas
Mule security-jaasMule security-jaas
Mule security-jaas
Praneethchampion
 
Mmc rest api user groups
Mmc rest api user groups Mmc rest api user groups
Mmc rest api user groups
Praneethchampion
 
Mule real-world-old
Mule real-world-oldMule real-world-old
Mule real-world-old
Praneethchampion
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Praneethchampion
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Praneethchampion
 
Mule soap
Mule soapMule soap
Mule soap
Praneethchampion
 
Mule security
Mule securityMule security
Mule security
Praneethchampion
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
Praneethchampion
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
Praneethchampion
 

Viewers also liked (20)

Mule drools
Mule drools Mule drools
Mule drools
 
Mule technology
Mule technologyMule technology
Mule technology
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
 
CSP Review Report_Final (1)
CSP Review Report_Final (1)CSP Review Report_Final (1)
CSP Review Report_Final (1)
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
 
Damaging damzelz' no.1
Damaging damzelz' no.1Damaging damzelz' no.1
Damaging damzelz' no.1
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
Mule security-jaas
Mule security-jaasMule security-jaas
Mule security-jaas
 
Mmc rest api user groups
Mmc rest api user groups Mmc rest api user groups
Mmc rest api user groups
 
Mule real-world-old
Mule real-world-oldMule real-world-old
Mule real-world-old
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
 
Mule soap
Mule soapMule soap
Mule soap
 
Mule security
Mule securityMule security
Mule security
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
 

Similar to Dataweave

Dataweave nagarjuna
Dataweave nagarjunaDataweave nagarjuna
Dataweave nagarjuna
Nagarjuna reddy
 
Dataweave Basic
Dataweave BasicDataweave Basic
Dataweave Basic
Nishant Kumar
 
Data weave
Data weave Data weave
Data weave
Khasim Saheb
 
Data weave
Data weave Data weave
Data weave
Anand kalla
 
Data weave
Data weave Data weave
Data weave
Sunil Komarapu
 
Data weave
Data weave Data weave
Data weave
Khan625
 
Dataweave by nagarjuna
Dataweave  by nagarjunaDataweave  by nagarjuna
Dataweave by nagarjuna
Nagarjuna reddy
 
Data weave
Data weaveData weave
Data weave
himajareddys
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
Ramakrishna kapa
 
Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
harika thamishetti
 
How to – data integrity checks in batch processing
How to – data integrity checks in batch processingHow to – data integrity checks in batch processing
How to – data integrity checks in batch processing
Son Nguyen
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
kunal vishe
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
Sindhu VL
 
Mule dataweave
Mule dataweaveMule dataweave
Mule data weave_3
Mule data weave_3Mule data weave_3
Mule data weave_3
kunal vishe
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
Son Nguyen
 
2 designer
2 designer2 designer
2 designer
Ravindra Gangwar
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
onlinetrainingplacements
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
Nandu List5
 

Similar to Dataweave (20)

Dataweave nagarjuna
Dataweave nagarjunaDataweave nagarjuna
Dataweave nagarjuna
 
Dataweave Basic
Dataweave BasicDataweave Basic
Dataweave Basic
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Data weave
Data weave Data weave
Data weave
 
Dataweave by nagarjuna
Dataweave  by nagarjunaDataweave  by nagarjuna
Dataweave by nagarjuna
 
Data weave
Data weaveData weave
Data weave
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
 
Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200Muledataweave10 161029032456-161119152200
Muledataweave10 161029032456-161119152200
 
How to – data integrity checks in batch processing
How to – data integrity checks in batch processingHow to – data integrity checks in batch processing
How to – data integrity checks in batch processing
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
 
Data weave documentation
Data weave documentationData weave documentation
Data weave documentation
 
Mule dataweave
Mule dataweaveMule dataweave
Mule dataweave
 
Mule data weave_3
Mule data weave_3Mule data weave_3
Mule data weave_3
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
2 designer
2 designer2 designer
2 designer
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
 
Data weave (MuleSoft)
Data weave (MuleSoft)Data weave (MuleSoft)
Data weave (MuleSoft)
 

More from Praneethchampion

How to use expression filter
How to use expression filter How to use expression filter
How to use expression filter
Praneethchampion
 
Mule execution
Mule executionMule execution
Mule execution
Praneethchampion
 
Mule soa
Mule soaMule soa
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
Praneethchampion
 
Mule for each scope header collection
Mule for each scope header collectionMule for each scope header collection
Mule for each scope header collection
Praneethchampion
 
Mule esb api layer
Mule esb api layerMule esb api layer
Mule esb api layer
Praneethchampion
 
Scatter gather flow in mule
Scatter gather flow in muleScatter gather flow in mule
Scatter gather flow in mule
Praneethchampion
 
Mule rabbitmq
Mule rabbitmqMule rabbitmq
Mule rabbitmq
Praneethchampion
 
Mule esb DataWeave
Mule esb DataWeaveMule esb DataWeave
Mule esb DataWeave
Praneethchampion
 
Idempotent filter in mule
Idempotent filter in muleIdempotent filter in mule
Idempotent filter in mule
Praneethchampion
 
Creating dynamic json in mule
Creating dynamic json in muleCreating dynamic json in mule
Creating dynamic json in mule
Praneethchampion
 

More from Praneethchampion (12)

How to use expression filter
How to use expression filter How to use expression filter
How to use expression filter
 
Mule execution
Mule executionMule execution
Mule execution
 
Mule soa
Mule soaMule soa
Mule soa
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule for each scope header collection
Mule for each scope header collectionMule for each scope header collection
Mule for each scope header collection
 
Mmc
Mmc Mmc
Mmc
 
Mule esb api layer
Mule esb api layerMule esb api layer
Mule esb api layer
 
Scatter gather flow in mule
Scatter gather flow in muleScatter gather flow in mule
Scatter gather flow in mule
 
Mule rabbitmq
Mule rabbitmqMule rabbitmq
Mule rabbitmq
 
Mule esb DataWeave
Mule esb DataWeaveMule esb DataWeave
Mule esb DataWeave
 
Idempotent filter in mule
Idempotent filter in muleIdempotent filter in mule
Idempotent filter in mule
 
Creating dynamic json in mule
Creating dynamic json in muleCreating dynamic json in mule
Creating dynamic json in mule
 

Recently uploaded

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

Dataweave

  • 2. Using the DataWeave Transformer • In Anypoint Studio, you can place a Transform Message element in a flow to create transformations using the DataWeave language. • The editor helps you do this by offering intelligent autocomplete suggestions, an output preview that is updated in real time as you make changes. • This generates a .dwl transformation file (or several of them) that stores your code and is packaged with your Mule application.
  • 3. • When adding a Transform Message element to a Mule Flow, it takes the elements from the incoming Mule Message as its inputs. It then performs the necessary actions to produce a Mule message as output for the next element in the flow
  • 4. • The DataWeave Text Editor GUI • The Transform Message element allows you to freely write DataWeave code. • If you click on an instance of the Transform Message element in your flow, its properties editor will be displayed. This editor is divided into three sections: • Input • Transform • Output
  • 5. Input Section In the main tab, a tree view shows the known metadata contents of the incoming Mule Message, allowing you to explore it and know what data is available for using as an input, and how to reference each part of it. If the Mule flow doesn’t expose Metadata about the elements you need from the incoming message, you can manually specify it. To do so, select the element of the input you desire to define, note that the pencil icon at the top right is no longer grayed out. Click this icon to open a new tab in your input section where you can define a sample with the structure of this data.
  • 6. When the input is of JSON or XML types, the sample input contains plain XML or JSON code. When the input is of type POJO or DataWeave, the sample input is written in DataWeave for more simplicity. In these cases the sample DataWeave code is merely a way to display the sample data, not a transformation in itself.
  • 7. Setting Reader Parameters • Some input formats, like CSV, allow you to define a reader with specific properties that make DataWeave parse inputs differently. Select the input element you wish to configure on the tree view of the input section, then click the gear icon.
  • 8. Transform Section • you write the actual DataWeave code that carries out the transform. Notice that changing the type of your output directive changes the output section of the editor. Although DataWeave as a language supports adding input directives and naming these by any name you like, in Studio the elements of the input message are implicitly considered input directives and so they don’t need to be defined in the header.
  • 9. If Studio has any metadata about the components that are upstream or downstream from your Transform Message element at the time when you add the component to your flow, a scaffolding for your DataWeave code is written out automatically, with as much depth as Studio can intelligently deduce. In some cases, this code may be enough to carry out the transformation you need, and no additional coding is needed. Sometimes, all you need to do is fill in the blank spaces in the scaffolding with references to the input fields, other times you may want to carry out more complex operations that involve aggregation, filtering, calculations, defining custom functions, etc and there you must write this out in DataWeave code.
  • 10. Re-scaffolding • Once you’ve added the Transform Message element to your flow, any further changes you make to the surrounding message processors and their metadata won’t affect your `.dw`l file. You may still click the Scaffolding button on the top left of the DataWeave properties editor any time you want and have a new scaffolding built, note that this will erase anything you’ve written in the DataWeave body. Doing this won’t affect any directives you defined in your header (except for the output directive). Use this button if you’ve made any changes to elements that come after the Transform Message element on the flow that expose metadata and don’t mind loosing what you’ve already written into the transform’s body.
  • 11. Referencing Existing Transforms Instead of defining a new .dwl file, you can reference an existing one by clicking theData Source button, selecting On File as the source and referencing the correct file.
  • 12. Handling Multiple Outputs A single Transform Message element can give shape to several different components of the output Mule message. Each of these output components must be defined in a separate .dwl file, written out in a separate tab of the Transform section. For example in one tab you may be defining the payload contents, in another those of an outbound property, and these will both be parts of the same output Mule message
  • 13. To add a new output, click the Plus sign at the bottom right of the section:new+output.png[image] A new tab will then appear, there you can specify where in the output Mule message to place the output of this DataWeave transform. In case you’re creating a new variable or property, you must also set a name for it.
  • 14. In the XML editor you can do the same by adding multiple child elements inside thedw:transform-message component. <dw:transform-message> <dw:set-payload resource="classpath:path/transform.dwl"/> <dw:set- variable variableName="myVariable" resource="classpath:path/transform.dwl"/> <dw:set-session-variable variableName="mySessionVariable" resource="classpath:path/transform.dwl"/> </dw:transform-message>
  • 15. Output Section • This section has two tabs, one of them shows you a neat expandable tree view of the output data structure, the other shows you a preview of what the actual output looks like, built from any sample data you provide in the input section. As you make changes in the transport section, notice how the data structure changes. The output of the transformer is made into the selected component of the output mule message. If your transformer has multiple outputs, the Preview tab will display the one corresponding to the currently selected transform.
  • 16. Using DataWeave Language Elsewhere • All components in Mule that support Mule Expression Language also support expressions written in DataWeave Language. To invoke an expression written in DataWeave language, simply invoke the dw() function, the expression will return whatever the transform outputs. • DataWeave expressions defined within this function work just as those defined within a Transform Message element, the only difference is that the output is returned into the expression’s result, wherever it may be.
  • 17. • For example, you can define a custom object and populate it with elements from the payload: • That same expression could be added inside a Logger, • within a MEL expression, to print out its result: dw(myobject:{id:payload.accountid, user:payload.user}) #[`dw(myobject:{id:payload.accountid, user:payload.user})`]