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

More Related Content

Viewers also liked

PrudentialProfile_Eng
PrudentialProfile_EngPrudentialProfile_Eng
PrudentialProfile_EngFunda Erbaş
 
jn_fs_tech_insider_march_032516
jn_fs_tech_insider_march_032516jn_fs_tech_insider_march_032516
jn_fs_tech_insider_march_032516Tony Evans
 
Challenge Taiwan 2016 Athlete's Guide
Challenge Taiwan 2016 Athlete's GuideChallenge Taiwan 2016 Athlete's Guide
Challenge Taiwan 2016 Athlete's Guide
Jeff Hung
 
Database component
Database component Database component
Database component
Sunil Komarapu
 
Idempotent filter with simple file
Idempotent filter with simple fileIdempotent filter with simple file
Idempotent filter with simple file
Sunil Komarapu
 
Maven ii
Maven iiMaven ii
Maven ii
Sunil Komarapu
 
Mule esb
Mule esbMule esb
Mule esb
Sunil Komarapu
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
Sunil Komarapu
 
Mule with velocity
Mule with velocityMule with velocity
Mule with velocity
Sunil Komarapu
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
Sunil Komarapu
 
Data weave
Data weave Data weave
Data weave
Sunil Komarapu
 
Mmc rest api user groups
Mmc rest api user groupsMmc rest api user groups
Mmc rest api user groups
Sunil Komarapu
 
Groovy with mule
Groovy with muleGroovy with mule
Groovy with mule
Sunil Komarapu
 
Los secretos de la mente millonaria t harv eker
Los secretos de la mente millonaria   t harv ekerLos secretos de la mente millonaria   t harv eker
Los secretos de la mente millonaria t harv eker
Fidel Mendoza
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
Sunil Komarapu
 
Tema 3
Tema 3Tema 3
Automatic documantation with mule
Automatic documantation with muleAutomatic documantation with mule
Automatic documantation with mule
Sunil Komarapu
 

Viewers also liked (20)

PrudentialProfile_Eng
PrudentialProfile_EngPrudentialProfile_Eng
PrudentialProfile_Eng
 
jn_fs_tech_insider_march_032516
jn_fs_tech_insider_march_032516jn_fs_tech_insider_march_032516
jn_fs_tech_insider_march_032516
 
engr.Eslam
engr.Eslamengr.Eslam
engr.Eslam
 
Challenge Taiwan 2016 Athlete's Guide
Challenge Taiwan 2016 Athlete's GuideChallenge Taiwan 2016 Athlete's Guide
Challenge Taiwan 2016 Athlete's Guide
 
Database component
Database component Database component
Database component
 
SUJIT_NANDI_1
SUJIT_NANDI_1SUJIT_NANDI_1
SUJIT_NANDI_1
 
Idempotent filter with simple file
Idempotent filter with simple fileIdempotent filter with simple file
Idempotent filter with simple file
 
Maven ii
Maven iiMaven ii
Maven ii
 
Mule esb
Mule esbMule esb
Mule esb
 
Paul Resume 2016
Paul Resume 2016Paul Resume 2016
Paul Resume 2016
 
How to use expression filter
How to use expression filterHow to use expression filter
How to use expression filter
 
Mule with velocity
Mule with velocityMule with velocity
Mule with velocity
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Data weave
Data weave Data weave
Data weave
 
Mmc rest api user groups
Mmc rest api user groupsMmc rest api user groups
Mmc rest api user groups
 
Groovy with mule
Groovy with muleGroovy with mule
Groovy with mule
 
Los secretos de la mente millonaria t harv eker
Los secretos de la mente millonaria   t harv ekerLos secretos de la mente millonaria   t harv eker
Los secretos de la mente millonaria t harv eker
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Tema 3
Tema 3Tema 3
Tema 3
 
Automatic documantation with mule
Automatic documantation with muleAutomatic documantation with mule
Automatic documantation with mule
 

Similar to Creating dynamic json

Create dynamic json using mule
Create dynamic json using muleCreate dynamic json using mule
Create dynamic json using mule
Son Nguyen
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic json
Anirban Sen Chowdhary
 
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 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
 
Validate soap request in mule
Validate soap request in muleValidate soap request in mule
Validate soap request in mule
Mohammed246
 
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
 
Validate Soap Request in Mule
Validate Soap Request in MuleValidate Soap Request in Mule
Validate Soap Request in Mule
irfan1008
 
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
 
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
 

Similar to Creating dynamic json (20)

Create dynamic json using mule
Create dynamic json using muleCreate dynamic json using mule
Create dynamic json using mule
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic 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 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
 
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
 
Validating a soap request in mule
Validating a soap request in mule Validating 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
 
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
 

More from Sunil Komarapu

WebServices
WebServicesWebServices
WebServices
Sunil Komarapu
 
Mule for each scope headerc ollection
Mule for each scope headerc ollectionMule for each scope headerc ollection
Mule for each scope headerc ollection
Sunil Komarapu
 
Mule esb Basics
Mule esb BasicsMule esb Basics
Mule esb Basics
Sunil Komarapu
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
Sunil Komarapu
 
Mule esb api layer
Mule esb api layerMule esb api layer
Mule esb api layer
Sunil Komarapu
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Sunil Komarapu
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
Sunil Komarapu
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
Sunil Komarapu
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
Sunil Komarapu
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
Sunil Komarapu
 
Jenkins
JenkinsJenkins
Jenkins2
Jenkins2Jenkins2
Jenkins2
Sunil Komarapu
 
Jenkins3
Jenkins3Jenkins3
Jenkins3
Sunil Komarapu
 
Maven part 1
Maven part 1Maven part 1
Maven part 1
Sunil Komarapu
 
Maven iii
Maven iiiMaven iii
Maven iii
Sunil Komarapu
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
Sunil Komarapu
 
Mule with quartz
Mule with quartzMule with quartz
Mule with quartz
Sunil Komarapu
 
Mule with rabbit mq
Mule with rabbit mqMule with rabbit mq
Mule with rabbit mq
Sunil Komarapu
 

More from Sunil Komarapu (19)

WebServices
WebServicesWebServices
WebServices
 
Maven
MavenMaven
Maven
 
Mule for each scope headerc ollection
Mule for each scope headerc ollectionMule for each scope headerc ollection
Mule for each scope headerc ollection
 
Mule esb Basics
Mule esb BasicsMule esb Basics
Mule esb Basics
 
Mule esb stripe
Mule esb stripeMule esb stripe
Mule esb stripe
 
Mule esb api layer
Mule esb api layerMule esb api layer
Mule esb api layer
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
 
How to use message properties component
How to use message properties componentHow to use message properties component
How to use message properties component
 
Anypoint data gateway
Anypoint data gatewayAnypoint data gateway
Anypoint data gateway
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
Jenkins
JenkinsJenkins
Jenkins
 
Jenkins2
Jenkins2Jenkins2
Jenkins2
 
Jenkins3
Jenkins3Jenkins3
Jenkins3
 
Maven part 1
Maven part 1Maven part 1
Maven part 1
 
Maven iii
Maven iiiMaven iii
Maven iii
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule with quartz
Mule with quartzMule with quartz
Mule with quartz
 
Mule with rabbit mq
Mule with rabbit mqMule with rabbit mq
Mule with rabbit mq
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
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
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
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
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
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
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
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
 
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
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
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
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
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...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
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
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
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
 
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
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 

Creating dynamic json

  • 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 