TCB - Wso2 - Esb - Foreach Mediator

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

More vats.namit@gmail.

com

TCB
WSO2 - ESB | FOREACH MEDIATOR thecodebu

FOREACH MEDIATOR

In the previous note, we saw how we can use custom classes as Mediators.

Moving on to cover other important mediation techniques, I was going through online documentation for 'FOREACH MEDIATOR' using this link -

https://docs.wso2.com/display/ESB490/Sample+18%3A+Transforming+a+Message+Using+ForEach+Mediator

when I realized, the sample code provided can be made more illustrative and a bit easier.
TCB

So code buddies, here we go with our version to create a small demo, using foreach mediator.
About Me

thecode
1. Kicking off with a sequence generation -
Declaring 'main2' as our sequence to imbibe foreach mediator - View my co

FB Page

Find me o

xml version - Get code o


<?xml version="1.0" encoding="UTF-8"?>
<sequence name="main2" trace="enable" xmlns="http://ws.apache.org/ns/synapse"> Follow
<in>
<foreach expression="//m0:getQuote/m0:request"
xmlns:m0="http://services.samples"
xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd"> html-css-b
<sequence>
<payloadFactory media-type="xml">
<format>
<m0:checkPriceRequest>
<m0:code>$1</m0:code>
</m0:checkPriceRequest>
</format>
<args> Exam 48
<arg evaluator="xml" expression="//m0:request/m0:symbol"/> Issuer: M
</args> Provided
</payloadFactory> Acclaim
</sequence>
</foreach>
<log level="full"/>
</in>
<out/>
</sequence>

Contact fo
2. Defining an API to use the above sequence -
Let's call it 'foreachAPI' -
Name
Email *

Message *

Send

XML version -
<api xmlns="http://ws.apache.org/ns/synapse" name="foreachAPI" context="/fe">
<resource methods="POST GET" inSequence="main2" outSequence="main2"/>
</api>

Blog archi
3. Let's also enable the debug logging, for the above API -
► 2020 (6
► 2018 (7
► 2017 (3
▼ 2016 (3
▼ Dece
WSO
FO
ME
WSO
WO
ME
Stepp
4. Time to hit the API. of A
Let's use the same XML provided in the tutorial i.e. stockQuoteReq.xml - Se

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:m0="http://services.samples"
xmlns:xsd="http://services.samples/xsd">
<soap:Header/>
<soap:Body>
<m0:getQuote>
<m0:request><m0:symbol>IBM</m0:symbol></m0:request>
<m0:request><m0:symbol>WSO2</m0:symbol></m0:request>
<m0:request><m0:symbol>MSFT</m0:symbol></m0:request>
</m0:getQuote> Total Page
</soap:Body>
</soap:Envelope>

Save it locally, and invade the directory where it is parked. Run the below curl command -

curl -d @stockQuoteReq.xml -H "Content-Type: application/soap+xml;charset=UTF- Popular Po


8" "http://172.16.2.34:8280/fe/foreachAPI"

5. Output obtained, all the things done using console, no need to deploy any code 😃
Mediator A
documenta
Mediator, it

Reading Ex
How to use
o/p xml - excel cells?
available @
<?xml version="1.0" encoding="UTF-8"?>
harma99/fi
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:m0="http://services.samples"
xmlns:xsd="http://services.samples/xsd">
<soap:Body>
<m0:getQuote>
<m0:checkPriceRequest>
<m0:code>IBM</m0:code>
</m0:checkPriceRequest> Hello Budd
<m0:checkPriceRequest> toe, but this
<m0:code>WSO2</m0:code> paper. We
</m0:checkPriceRequest> that allows
<m0:checkPriceRequest>
<m0:code>MSFT</m0:code>
</m0:checkPriceRequest>
</m0:getQuote>
</soap:Body>
</soap:Envelope> custom cla
on to cover
Keep experimenting buddies, share your thoughts!
at December 28, 2016

Labels: API, custom mediator, ESB, esb5, fedora, foreach mediator, sequence, WSO2
using mous
Complete c
4 comments: https:/...

sheela rajesh 4 May 2019 at 04:39


I have to appreciate you for your great work which you had done in your blog.i want you to add more like this.
JAVA Training in Chennai
JAVA Course in Chennai
Digital Marketing Course in Chennai code writte
Python Training in Chennai very basic
Big data training in chennai complete c
Selenium Training in Chennai
JAVA Training in Chennai
JAVA Course in Chennai
Reply Delete

Replies time. A com


developers
thecodebuddy 5 May 2019 at 09:33
Thanks a lot for sharing the appreciation! :)
Will surely try to add more of such matter once time permits. :)
Delete

recently, an
Reply
developers
banging. A
w...
saran 7 June 2020 at 22:43 JAVA code
"It is actually a great and helpful piece of information. I am satisfied that you simply shared this helpful information with us. Please stay us comparison
informed like this. Thanks for sharing. Hello Budd
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in useful piec
OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in you in hand
Velachery comparison
" O(n^2) vs O
Reply Delete the max co
numerical S
Hello Budd
question re
saran 20 June 2020 at 19:04 so thought
It's very Wonderful to visit your site...Enjoy Reading your Articles...informative Blogs About Java...Keep doing the same Given a str
Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in
OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in
Velachery
Search Th

Reply Delete

Enter your comment...


Blog archi

► 2020 (6
► 2018 (7
Comment as: thecodebuddy ( Sign out
► 2017 (3
▼ 2016 (3
Publish Preview Notify me ▼ Dece
WSO
FO
ME
WSO
Newer Post Home Older Post WO
ME
Stepp
Subscribe to: Post Comments (Atom)
of A
Se
Featured post

How to take backup of MYSQL tables daily and remove the older backups
In day to day heavy transactions happening in our DB, we sometimes wish to retain the previous states of the tables. This not only prevents ... Newsletter

Email addr

WSO2 ESB - How to use PayloadFactory Mediator


How to use PayloadFactory Mediator As per the WSO2-ESB documentation of PayloadFactory Mediator, it is stated that this me...

Reading Excel file using java code


How to use JAVA code to read the excel cells? Here it goes - Full code is available @ https://github.com/namitsharma99/fileHandlingUs...

JAVASCRIPT SAMPLES - TIC TAC TOE GAME & DYNAMIC TABLE CREATION IN JSP
Hello Buddies. It's time to play tic-tac-toe, but this time, not with pen and paper. We will create our own page that allows us to ...
Ads

Head First
A...
INR 870.0

Shop n
Labels

AJAX algo Amazon Web Services Android Angular 2 Angular Components Apache httpd apache poi API API GATEWAY APK Automate build AWS AWS and Gmail AWS Email AWS Lambda AWS Lambda No
SES backup binary search binary tree Bootstrap browser issue BST chat Cheat sheet chrome class mediator cloning code code-snippet Complexity Analysis concurrency consumer core java css CSV cu
structures Data Structures and Algorithms database management deep download DSA DTMF eclipse EDM Electronic Digital Music electronic music Electronics Enum epic violins ESB esb5 event

fedora file firefox foreach mediator game games Git Git Hub Git Lab Git Repo Go Go Tutorials GoLang hello world Hibernate hip hop html HTTP GET POST PUT DELETE J2EE Java JAVA.
Jenkins jquery jQuery in Angular 2 JS JSP kafka KEYGEN LAMBDA linear search mediation messaging microservices mozilla MSTSC multi threading MySQL NG-2 NODEJS NPM Path Annotations Payload
PUTTY quick reference read text file read write csv remote access REST S3 schedulers sequence Server shallow shooting game small programs snake game socket programming Speech to Text springboot S
questions tables text file writer thecodebuddy tic-tac-toe game time complexity topic Trance TUNNEL unix upload version-check white paper WINDOWS Workbench WSO2 WSO2 ESB XML JSON transformation

Awesome Inc. theme. Powered by Blogger.

You might also like