我正在尝试调用(Shopify Orders API)分页的REST API。并且需要汇总所有响应,需要一个响应。但是找不到任何分页介体或任何类似的方法。
我做了一个变通,我递归地调用了相同的序列,并且进行了分页。我遇到的问题是聚合器无法按我预期的方式工作,它没有将分页的响应聚合到单个响应中。
在这里,我附加了ESB序列代码和Shopify的响应正文
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="OrderPaginationSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property name="hit_text" value="### Shopify All Order Pagination Sequence ###"/>
<property expression="get-property('pageCount')" name="pageCount"/>
<property expression="get-property('synapse_it_count')" name="synapseCount"/>
</log>
<filter description="" regex="true" source="get-property('synapse_it_count') <= get-property('pageCount') ">
<then>
<property expression="get-property('synapse_it_count')+1"
name="synapse_it_count" scope="default" type="STRING"/>
<property description="URL Expression"
expression="fn:concat('/','orders.json?page=',get-property('synapse_it_count'),'&limit=250')"
name="uri.var.url_expression" scope="default" type="STRING"/>
<log level="custom">
<property expression="get-property('uri.var.url_expression')" name="Shopify Order Paggiing Sequence Sequence"/>
</log>
<call-template description="" target="SeqTempShopifyApi"/>
<log level="custom"/>
<iterate expression="//orders" id="orderPaginationItr" sequential="true">
<target>
<sequence>
<log level="custom">
<property expression="$body" name="hit_text"/>
</log>
</sequence>
</target>
</iterate>
<aggregate id="orderPaginationItr">
<completeCondition timeout="10">
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete expression="//orders">
<log level="custom">
<property name="message response" value=""/>
</log>
</onComplete>
</aggregate>
<sequence key="OrderPaginationSequence"/>
</then>
<else/>
</filter>
</sequence>
Shopify Order API Documentation
Shopify订单响应
{
"orders": [
{
"id": 450789469,
"email": "bob.norman@hostmail.com"
}
]
}