WSO2 中的顺序后端调用 EI/ESB
Sequential back-end calls in WSO2 EI/ESB
在我的例子中,第一个后端调用的响应采用 对象数组 格式,如下所示:
回复:
"Entity": {
"related-List": [
{
"fname": "abc",
"lname": "xyz",
"bdate": "2013-01-25",
"accType": "Cur",
"accNum": "54736",
"bal": 901,
"address": "USA"
},
{
"fname": "def",
"lname": "pqr",
"bdate": "2013-01-25",
"accType": "Sav",
"accNum": "12345",
"bal": 901,
"address": "USA"
},
{
"fname": "ghi",
"lname": "stu",
"bdate": "2013-01-25",
"accType": "Dep",
"accNum": "87654",
"bal": 901,
"address": "USA"
}
]
}
*************/
所以在第二次调用中,我想使用响应中的 "accType" 和 "accNum" 并进行后端调用以获取响应数组中存在的对象数。为此,我需要像这样使用 Iterate 或 ForEach:
<foreach>
<call>
<endpoint>
<http method="POST" uri-template="http://localhost:6754/v2/{accType}/{accNum}"/>
</endpoint>
</call>
</foreach>
或
<iterate>
<call>
<endpoint>
<http method="POST" uri-template="http://localhost:6754/v2/{accType}/{accNum}"/>
</endpoint>
</call>
</iterate>
正确的实现方式是什么?
您不能在 Foreach 调解器中使用 Send 或 Call 调解器。因此,您必须使用 Iterate 调解器。您可以将 Iterate mediator expression 用作 json-eval($. Entity.related-List) 并遍历数组。
在我的例子中,第一个后端调用的响应采用 对象数组 格式,如下所示:
回复:
"Entity": {
"related-List": [
{
"fname": "abc",
"lname": "xyz",
"bdate": "2013-01-25",
"accType": "Cur",
"accNum": "54736",
"bal": 901,
"address": "USA"
},
{
"fname": "def",
"lname": "pqr",
"bdate": "2013-01-25",
"accType": "Sav",
"accNum": "12345",
"bal": 901,
"address": "USA"
},
{
"fname": "ghi",
"lname": "stu",
"bdate": "2013-01-25",
"accType": "Dep",
"accNum": "87654",
"bal": 901,
"address": "USA"
}
]
}
*************/
所以在第二次调用中,我想使用响应中的 "accType" 和 "accNum" 并进行后端调用以获取响应数组中存在的对象数。为此,我需要像这样使用 Iterate 或 ForEach:
<foreach>
<call>
<endpoint>
<http method="POST" uri-template="http://localhost:6754/v2/{accType}/{accNum}"/>
</endpoint>
</call>
</foreach>
或
<iterate>
<call>
<endpoint>
<http method="POST" uri-template="http://localhost:6754/v2/{accType}/{accNum}"/>
</endpoint>
</call>
</iterate>
正确的实现方式是什么?
您不能在 Foreach 调解器中使用 Send 或 Call 调解器。因此,您必须使用 Iterate 调解器。您可以将 Iterate mediator expression 用作 json-eval($. Entity.related-List) 并遍历数组。