WSO2 EI/ESB:用于循环实施 [英] WSO2 EI/ESB: For loop implementation
问题描述
我想在WSO2 Integration Studio中实现一个简单的" for循环".
I want to implement a simple "for loop" in WSO2 Integration Studio.
例如:
我正在实现总线路由API.每辆巴士有10个不同的站点.我想从后端服务中获取10个停靠点.一个正常的for循环是:
I am implementing a bus-route API. Every bus has 10 different stops. I want to fetch the 10 stops from the back-end service. A normal for-loop for this would be:
for(i=0;i<10;i++)
{
//back-end call
<call>
<endpoint>
<http method="get" uri-template="https://backend.com/city+i"/>
</endpoint>
</call>
}
注意::在上面的for循环中,后端调用具有路径参数,例如city,应将其迭代为city1,city2,city3,..... city9.
NOTE: In the above for loop, the back-end call has path parameter like city which should be iterated as city1, city2, city3,..... city9.
我如何在WSO2 EI/ESB Integration Studio中实现这一点?
How do I implement this in WSO2 EI/ESB Integration Studio?
推荐答案
一种简单的方法是使用数组中的数字定义样本有效负载并对其进行迭代. (如果预定义了迭代次数,这将起作用)例如:[{"value":1},{"value":2},{"value":3},...]
One simple way would be to define a sample payload with the numbers inside an array and iterate through it. (This would work if the number of the iterations are predefined) For eg: [{"value" : 1},{"value" :2},{"value" : 3}, ... ]
否则,您可以编写自定义类介体并实现您的逻辑.
Or else you can write a custom class mediator and implement your logic.
还有一种有趣的方法可以在数据库的帮助下实现while循环. http://bsenduran.blogspot. com/2017/08/while-loop-in-wso2-esb.html?m = 1
Also there is a fun way to implement a while loop with the help of database. http://bsenduran.blogspot.com/2017/08/while-loop-in-wso2-esb.html?m=1
这篇关于WSO2 EI/ESB:用于循环实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!