Search code examples
wso2-data-services-serverwso2-esb

wso2 ESB iterate mediator to handle nullity


I call a wso2 DSS data service, which will return available database rows as response. I use an Iterate mediator to iterate over the elements and perform the required task.

My issue is when the database has no entries, the data service doesn't return a response but the iterate mediator starts to iterate and throws up an exception in the ESB. Is there a property to tell the iterate mediator only to iterate if elements are available? Similar to a java if (null) check


Solution

  • Check if there is data before calling iterate mediator :

    <filter xpath="boolean($body/something)">
        <then>
            --> iterate
        </then>
    </filter>
    

    xpath expression return true if "something" node exist