SlideShare a Scribd company logo
By Anirban Sen Chowdhary
Mule ESB has multiple options to create dynamic payload. The payload used in Mule
can be of multiple types like JSON, XML or simple Text payload.
With Mule we can dynamically generate any type of payload at any point of time in
the flow.
We will see how to create a simple JSON payload dynamically within a Mule flow and
post that JSON to an external service and get a response.
It’s quite simple and we will see how we can generate a JSON in a flow.
Creating dynamic json
Let us consider we need to create a JSON file as following :-
{
"myService": {
"messageHeader": {
"messageId": "ec75da88e64a739e12c126",
"messageDateTime": "2014-09-18T14:07:46+0530"
},
"mesageBody": {
"myServiceRequest": {
"Amount": 3520,
"ConsumerId": "ABC-T14005-AFF",
"Timestamp": "2014-10-27T18:36:18+0700"
}
}
}
}
Now, we need to create this flow in our Mule flow and send the JSON request created to the
external service and will get a response. We will assign the JSON elements value from flow
variables for now, but you can use message inbound properties or other ways to assign the
flow variables dynamically within the flow.
We will use Mule Expression Transformer to create this JSON request. As per Mule
documentation here
https://developer.mulesoft.com/docs/display/current/Expression+Transformer+Referenc
e :-
The Expression Transformer executes one or more expressions on the current message.
The results of these expressions becomes the payload of the current message.
Let’s consider our Mule flow as following :-
Here you can see, the expression transformer is creating the JSON request which is send to the
external web service. The flow variables are used to set the value and you can assign the variables
dynamically in your way.
Now let’s test our flow by placing by hitting the url http://localhost:8085/rc/test
on browser as follows, :-
The JSON request will be generated in the flow and with that request it will be
posted to the external web service which will return a response
Now, we can see in our logger the JSON request generated and the JSON response from
the external service in return :-
So, here you can see how to set a Dynamic JSON and can be send to the external
service to get a response…. you can try this with your requirement as well and set
the value dynamically in the flow variables or can use other dynamic options like
inbound properties etc !!!….
In my next slide I will bring some other techniques in Mule implementation .
Hope you have enjoyed this simpler version.
Keep sharing your knowledge and let our Mule community grow 
Creating dynamic json

More Related Content

PPTX
Soap In Mule
PPTX
Validate Soap Request in Mule
PPTX
Validating a soap request in mule
PPTX
Scheduling and monitoring with java in mule
PPTX
Mule soap
PPTX
Creating dynamic json in Mule
 
PPTX
Validate soap request in mule
PPTX
Soap request in mule
Soap In Mule
Validate Soap Request in Mule
Validating a soap request in mule
Scheduling and monitoring with java in mule
Mule soap
Creating dynamic json in Mule
 
Validate soap request in mule
Soap request in mule

What's hot (6)

PPTX
Soap in mule
PPTX
Filtering jms messages with mule
PPTX
Mule soap
PPTX
Mule velocity
PPT
Mule and web services
PPTX
Web service vm in mule
Soap in mule
Filtering jms messages with mule
Mule soap
Mule velocity
Mule and web services
Web service vm in mule
Ad

Viewers also liked (12)

PPTX
Splitting with mule part2
PPTX
Json to json transformation in mule
PPTX
Mule batch job
PPTX
Mapping and listing with mule
PPTX
Mule with velocity
PPTX
Designing rest with raml
PPTX
Splitting with mule
PPTX
Welcome data weave
PPTX
Dynamic file attribute
PPTX
Xml to xml transformation in mule
PPTX
Getting anypoint studios all versions
DOCX
Collection Splitter Aggregator in Mule ESB
Splitting with mule part2
Json to json transformation in mule
Mule batch job
Mapping and listing with mule
Mule with velocity
Designing rest with raml
Splitting with mule
Welcome data weave
Dynamic file attribute
Xml to xml transformation in mule
Getting anypoint studios all versions
Collection Splitter Aggregator in Mule ESB
Ad

Similar to Creating dynamic json (20)

PPTX
Create dynamic json using mule
PPTX
Creating dynamic json in mule
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Json
PPTX
Json to json transformation in mule
PPTX
Transformation jsontojsonesb
PPTX
Json to json transformation in mule
PPTX
Transformation jsontojsonesb
PPTX
Transformation jsontojsonesb
PDF
Mule esb and_relevant_components
PPTX
Adding dynamic file
PDF
Mule ESB Interview or Certification questions
PPTX
Setting filedynamically
Create dynamic json using mule
Creating dynamic json in mule
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Json
Json to json transformation in mule
Transformation jsontojsonesb
Json to json transformation in mule
Transformation jsontojsonesb
Transformation jsontojsonesb
Mule esb and_relevant_components
Adding dynamic file
Mule ESB Interview or Certification questions
Setting filedynamically

More from Anirban Sen Chowdhary (20)

PPTX
Change the game with Game changer
PPTX
Ring central desktop app overview
PPTX
Overview in ringcentral digital line
PPTX
Some basics with ring central
PPTX
Ring central and python
PPTX
RingCentral application development overview
PPTX
Cloze connect ringcentral
PPTX
Overview on ring central errors part 4
PPTX
Setting up your ring central sandbox in steps
PPTX
Overview on ring central errors: part 2
PPTX
Overview on ring central errors
PPTX
Call recording overview ring central
PPTX
Ring central engaging with amazon alexa
PPTX
How ring central sdk changing the game
PPTX
When ring central connect salesforce
PPTX
Mule 4 connecting ring central
PPTX
Ring central sdk
PPTX
Ring central with okta
PPTX
Ring central connecting salesforce overview
PPTX
Ring central call logs overview (part 2)
Change the game with Game changer
Ring central desktop app overview
Overview in ringcentral digital line
Some basics with ring central
Ring central and python
RingCentral application development overview
Cloze connect ringcentral
Overview on ring central errors part 4
Setting up your ring central sandbox in steps
Overview on ring central errors: part 2
Overview on ring central errors
Call recording overview ring central
Ring central engaging with amazon alexa
How ring central sdk changing the game
When ring central connect salesforce
Mule 4 connecting ring central
Ring central sdk
Ring central with okta
Ring central connecting salesforce overview
Ring central call logs overview (part 2)

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)

Creating dynamic json

  • 1. By Anirban Sen Chowdhary
  • 2. Mule ESB has multiple options to create dynamic payload. The payload used in Mule can be of multiple types like JSON, XML or simple Text payload. With Mule we can dynamically generate any type of payload at any point of time in the flow. We will see how to create a simple JSON payload dynamically within a Mule flow and post that JSON to an external service and get a response. It’s quite simple and we will see how we can generate a JSON in a flow.
  • 4. Let us consider we need to create a JSON file as following :- { "myService": { "messageHeader": { "messageId": "ec75da88e64a739e12c126", "messageDateTime": "2014-09-18T14:07:46+0530" }, "mesageBody": { "myServiceRequest": { "Amount": 3520, "ConsumerId": "ABC-T14005-AFF", "Timestamp": "2014-10-27T18:36:18+0700" } } } } Now, we need to create this flow in our Mule flow and send the JSON request created to the external service and will get a response. We will assign the JSON elements value from flow variables for now, but you can use message inbound properties or other ways to assign the flow variables dynamically within the flow.
  • 5. We will use Mule Expression Transformer to create this JSON request. As per Mule documentation here https://developer.mulesoft.com/docs/display/current/Expression+Transformer+Referenc e :- The Expression Transformer executes one or more expressions on the current message. The results of these expressions becomes the payload of the current message.
  • 6. Let’s consider our Mule flow as following :- Here you can see, the expression transformer is creating the JSON request which is send to the external web service. The flow variables are used to set the value and you can assign the variables dynamically in your way.
  • 7. Now let’s test our flow by placing by hitting the url http://localhost:8085/rc/test on browser as follows, :- The JSON request will be generated in the flow and with that request it will be posted to the external web service which will return a response
  • 8. Now, we can see in our logger the JSON request generated and the JSON response from the external service in return :-
  • 9. So, here you can see how to set a Dynamic JSON and can be send to the external service to get a response…. you can try this with your requirement as well and set the value dynamically in the flow variables or can use other dynamic options like inbound properties etc !!!….
  • 10. In my next slide I will bring some other techniques in Mule implementation . Hope you have enjoyed this simpler version. Keep sharing your knowledge and let our Mule community grow 