DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Rethinking Enterprise Integration: The Understated Role of Enterprise Service Bus (ESB)
  • Creating a Mule ESB Sample Hello World Application

Trending

  • How to Parse Large XML Files in PHP Without Running Out of Memory
  • Spring AI Advisors: Chat Memory, Token Tracking, and Message Logging
  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • AI Paradigm Shift: Analytics Without SQL
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Nested Iterator with WSO2 ESB

Nested Iterator with WSO2 ESB

By 
Achala Chathuranga Aponso user avatar
Achala Chathuranga Aponso
·
Feb. 23, 13 · Interview
Likes (0)
Comment
Save
Tweet
Share
7.4K Views

Join the DZone community and get the full member experience.

Join For Free
Please find the following sample which demonstrates the Nested iterator.

The following is the source of the configuration.

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
    <registry provider="org.wso2.carbon.mediation.registry.WSO2Registry">
        <parameter name="cachableDuration">15000</parameter>
    </registry>
    <sequence name="IterateMediatorSequence">
        <iterate xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" xmlns:m0="http://services.samples" id="iterate1" preservePayload="true" attachPath="//m0:getQuotes" expression="//m0:getQuotes/m0:getQuote">
            <target>
                <sequence>
                    <log level="full">
                        <property name="target1" value="************After 1st Iterate before 2nd Iterate*************"/>
                    </log>
                    <iterate id="iterate2" preservePayload="true" attachPath="//m0:getQuote" expression="//m0:getQuotes/m0:getQuote/m0:request">
                        <target>
                            <sequence>
                                <log level="full">
                                    <property name="target2333" value="************After 2nd Iterate and before payload factory*************"/>
                                </log>
                                <payloadFactory>
                                    <format>
                                        <m0:getQuote>
                                            <m0:request>
                                                <m0:symbol>$1</m0:symbol>
                                            </m0:request>
                                        </m0:getQuote>
                                    </format>
                                    <args>
                                        <arg expression="//m0:getQuote/m0:request/m0:symbol"/>
                                    </args>
                                </payloadFactory>
                                <log level="full">
                                    <property name="target1" value="************after payload factory*************"/>
                                </log>
                                <send>
                                    <endpoint>
                                        <address uri="http://localhost:9001/services/SimpleStockQuoteService"/>
                                    </endpoint>
                                </send>
                            </sequence>
                        </target>
                    </iterate>
                </sequence>
            </target>
        </iterate>
    </sequence>
    <sequence name="aggregateMessages">
        <aggregate id="iterate2">
            <completeCondition>
                <messageCount min="-1" max="-1"/>
            </completeCondition>
            <onComplete xmlns:ns="http://org.apache.synapse/xsd" xmlns:ns3="http://org.apache.synapse/xsd" xmlns:m0="http://services.samples" expression="//m0:getQuoteResponse">
                <log level="full"/>
                <aggregate id="iterate1">
                    <completeCondition>
                        <messageCount min="-1" max="-1"/>
                    </completeCondition>
                    <onComplete expression="//m0:getQuoteResponse">
                        <send/>
                    </onComplete>
                </aggregate>
            </onComplete>
        </aggregate>
    </sequence>
    <sequence name="fault">
        <log level="full">
            <property name="MESSAGE" value="Executing default 'fault' sequence"/>
            <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
            <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
        </log>
        <drop/>
    </sequence>
    <sequence name="main">
        <in>
            <sequence key="IterateMediatorSequence"/>
        </in>
        <out>
            <sequence key="aggregateMessages"/>
        </out>
    </sequence>
</definitions> 

Use the following request with soapui in order to test the above sample.

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
 <m0:getQuotes xmlns:m0="http://services.samples">
<m0:getQuote>
<m0:request>
<m0:symbol>SUN9</m0:symbol>
</m0:request>
<m0:request>
<m0:symbol>SUN10</m0:symbol>
</m0:request>
</m0:getQuote>
</m0:getQuotes>
</soapenv:Body>
</soapenv:Envelope>
From the second iterate mediator, messages retrieved from the first iterator are again iterated into smaller messages as below

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<m0:getQuote xmlns:m0="http://services.samples">
<m0:request>
<m0:symbol>SUN10</m0:symbol>
</m0:request>
</m0:getQuote>
</soapenv:Body>
</soapenv:Envelope> 

Enterprise service bus

Published at DZone with permission of Achala Chathuranga Aponso. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Rethinking Enterprise Integration: The Understated Role of Enterprise Service Bus (ESB)
  • Creating a Mule ESB Sample Hello World Application

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook