SlideShare a Scribd company logo
Creating Dynamic JSON in Mule
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.
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+Reference :-
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 in mule

More Related Content

What's hot

Mule soap
Mule soapMule soap
Mule soap
Khasim Saheb
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Mule
irfan1008
 
Stored procedure in Mule
Stored procedure in MuleStored procedure in Mule
Stored procedure in Mule
Khasim Saheb
 
Mule soap
Mule soapMule soap
Mule soap
D.Rajesh Kumar
 
Soap in mule
Soap in muleSoap in mule
Soap in mule
D.Rajesh Kumar
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
Prabhat gangwar
 
Accessing jms in mule using groovy
Accessing jms in mule using groovyAccessing jms in mule using groovy
Accessing jms in mule using groovy
Anirban Sen Chowdhary
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
Praneethchampion
 

What's hot (8)

Mule soap
Mule soapMule soap
Mule soap
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Mule
 
Stored procedure in Mule
Stored procedure in MuleStored procedure in Mule
Stored procedure in Mule
 
Mule soap
Mule soapMule soap
Mule soap
 
Soap in mule
Soap in muleSoap in mule
Soap in mule
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
 
Accessing jms in mule using groovy
Accessing jms in mule using groovyAccessing jms in mule using groovy
Accessing jms in mule using groovy
 
Soap request in mule
Soap request in mule Soap request in mule
Soap request in mule
 

Viewers also liked

Mule security-jaas
Mule security-jaasMule security-jaas
Mule security-jaas
Praneethchampion
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
Praneethchampion
 
CSP Review Report_Final (1)
CSP Review Report_Final (1)CSP Review Report_Final (1)
CSP Review Report_Final (1)
Zachary (Eric) Cissna
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
Praneethchampion
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
Praneethchampion
 
Mule real-world-old
Mule real-world-oldMule real-world-old
Mule real-world-old
Praneethchampion
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
Praneethchampion
 
How to use expression filter
How to use expression filter How to use expression filter
How to use expression filter
Praneethchampion
 
Mule velocity
Mule velocityMule velocity
Mule velocity
Praneethchampion
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
Praneethchampion
 
Mmc rest api user groups
Mmc rest api user groups Mmc rest api user groups
Mmc rest api user groups
Praneethchampion
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
Praneethchampion
 
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
 
Mule security
Mule securityMule security
Mule security
Praneethchampion
 
Mule soap
Mule soapMule soap
Mule soap
Praneethchampion
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
Praneethchampion
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
Praneethchampion
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
Praneethchampion
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Praneethchampion
 
Documantation with mule
Documantation with mule Documantation with mule
Documantation with mule
Praneethchampion
 

Viewers also liked (20)

Mule security-jaas
Mule security-jaasMule security-jaas
Mule security-jaas
 
Mule anypoint exchange
Mule anypoint exchangeMule anypoint exchange
Mule anypoint exchange
 
CSP Review Report_Final (1)
CSP Review Report_Final (1)CSP Review Report_Final (1)
CSP Review Report_Final (1)
 
Webservice vm in mule
Webservice vm in muleWebservice vm in mule
Webservice vm in mule
 
Mule google connectors
Mule google connectorsMule google connectors
Mule google connectors
 
Mule real-world-old
Mule real-world-oldMule real-world-old
Mule real-world-old
 
Mule oracle connectors
Mule oracle connectorsMule oracle connectors
Mule oracle connectors
 
How to use expression filter
How to use expression filter How to use expression filter
How to use expression filter
 
Mule velocity
Mule velocityMule velocity
Mule velocity
 
Introduction to mule esb
Introduction to mule esbIntroduction to mule esb
Introduction to mule esb
 
Mmc rest api user groups
Mmc rest api user groups Mmc rest api user groups
Mmc rest api user groups
 
Mule quartz
Mule quartz Mule quartz
Mule quartz
 
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
 
Mule security
Mule securityMule security
Mule security
 
Mule soap
Mule soapMule soap
Mule soap
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
 
Groovy in Mule
Groovy in MuleGroovy in Mule
Groovy in Mule
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
Documantation with mule
Documantation with mule Documantation with mule
Documantation with mule
 

Similar to Creating dynamic json in mule

Create dynamic json using mule
Create dynamic json using muleCreate dynamic json using mule
Create dynamic json using mule
Son Nguyen
 
Json
JsonJson
Json
manavp
 
Splitting with mule part2
Splitting with mule part2Splitting with mule part2
Splitting with mule part2
Anirban Sen Chowdhary
 
Validating soap request in mule
Validating soap request in mule Validating soap request in mule
Validating soap request in mule
mdfkhan625
 
Validating a soap request in mule
Validating a soap request in muleValidating a soap request in mule
Validating a soap request in mule
Khan625
 
Validating a soap request in mule
Validating a soap request in mule Validating a soap request in mule
Validating a soap request in mule
AbdulImrankhan7
 
Validating soap request in mule
Validating soap request in mule Validating soap request in mule
Validating soap request in mule
javeed_mhd
 
Validate soap request in mule
Validate soap request in muleValidate soap request in mule
Validate soap request in mule
Sunil Komarapu
 
Validating a soap request in mule
Validating a soap request in muleValidating a soap request in mule
Validating a soap request in mule
Rajkattamuri
 
Validate soap request in mule
Validate soap request in muleValidate soap request in mule
Validate soap request in mule
Hasan Syed
 
Web application with mule
Web application with muleWeb application with mule
Web application with mule
Anirban Sen Chowdhary
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
Davide Rapacciuolo
 
Webapplicationwithmule by raju
Webapplicationwithmule by rajuWebapplicationwithmule by raju
Webapplicationwithmule by raju
Raju N
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
Antonio Pellegrino
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
Germano Barba
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
Antonio Pellegrino
 
Playing with cxf interceptor in mule
Playing with cxf interceptor in mulePlaying with cxf interceptor in mule
Playing with cxf interceptor in mule
Anirban Sen Chowdhary
 
Using ajax in mule
Using ajax in muleUsing ajax in mule
Using ajax in mule
Anirban Sen Chowdhary
 
Webapplicationwithmule by nagarjuanreddy
Webapplicationwithmule by nagarjuanreddyWebapplicationwithmule by nagarjuanreddy
Webapplicationwithmule by nagarjuanreddy
Nagarjuna reddy
 
Json to json esb transformation
Json to json esb transformationJson to json esb transformation
Json to json esb transformation
Domenico Schiavone
 

Similar to Creating dynamic json in mule (20)

Create dynamic json using mule
Create dynamic json using muleCreate dynamic json using mule
Create dynamic json using mule
 
Json
JsonJson
Json
 
Splitting with mule part2
Splitting with mule part2Splitting with mule part2
Splitting with mule part2
 
Validating soap request in mule
Validating soap request in mule Validating soap request in mule
Validating soap request in mule
 
Validating a soap request in mule
Validating a soap request in muleValidating a soap request in mule
Validating a soap request in mule
 
Validating a soap request in mule
Validating a soap request in mule Validating a soap request in mule
Validating a soap request in mule
 
Validating soap request in mule
Validating soap request in mule Validating soap request in mule
Validating soap request in mule
 
Validate soap request in mule
Validate soap request in muleValidate soap request in mule
Validate soap request in mule
 
Validating a soap request in mule
Validating a soap request in muleValidating a soap request in mule
Validating a soap request in mule
 
Validate soap request in mule
Validate soap request in muleValidate soap request in mule
Validate soap request in mule
 
Web application with mule
Web application with muleWeb application with mule
Web application with mule
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
 
Webapplicationwithmule by raju
Webapplicationwithmule by rajuWebapplicationwithmule by raju
Webapplicationwithmule by raju
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
 
Playing with cxf interceptor in mule
Playing with cxf interceptor in mulePlaying with cxf interceptor in mule
Playing with cxf interceptor in mule
 
Using ajax in mule
Using ajax in muleUsing ajax in mule
Using ajax in mule
 
Webapplicationwithmule by nagarjuanreddy
Webapplicationwithmule by nagarjuanreddyWebapplicationwithmule by nagarjuanreddy
Webapplicationwithmule by nagarjuanreddy
 
Json to json esb transformation
Json to json esb transformationJson to json esb transformation
Json to json esb transformation
 

More from 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
 
Dataweave
Dataweave Dataweave
Dataweave
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
 
Mmc
Mmc Mmc
Mule esb api layer
Mule esb api layerMule esb api layer
Mule esb api layer
Praneethchampion
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
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 drools
Mule drools Mule drools
Mule drools
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
 

More from Praneethchampion (13)

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
 
Dataweave
Dataweave Dataweave
Dataweave
 
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
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
 
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 drools
Mule drools Mule drools
Mule drools
 
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
 

Recently uploaded

Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
ScyllaDB
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
HarpalGohil4
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Ukraine
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
ScyllaDB
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 

Recently uploaded (20)

Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Discover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched ContentDiscover the Unseen: Tailored Recommendation of Unwatched Content
Discover the Unseen: Tailored Recommendation of Unwatched Content
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)AWS Certified Solutions Architect Associate (SAA-C03)
AWS Certified Solutions Architect Associate (SAA-C03)
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
GlobalLogic Java Community Webinar #18 “How to Improve Web Application Perfor...
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's TipsGetting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
Getting the Most Out of ScyllaDB Monitoring: ShareChat's Tips
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 

Creating dynamic json in mule

  • 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.
  • 3.
  • 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+Reference :- 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 