问题
I have a payload factory like below:
<payloadFactory media-type="json">
<format>[{"value" : 1},{"value" : 2},{"value" : 3}]</format>
<args/>
</payloadFactory>
<iterate expression="json-eval($)" id="iterate-over-nameAddress">
<call>
<endpoint>
<http method="get" uri-template="https://backend.com/names/value+{uri.var.value}/address"/>
</endpoint>
</call>
</iterate>
In the above code, in backend call, I want the path-parameter "value+{uri.var.value}" to change dynamically according to the iterate expression. The path param should change like value1, value2, value3... for every iteration.
How do I implement this?
回答1:
Since you are iterating with a dummy payload, you can try the following. Instead of having the values as 1, 2, 3 have the entire value thing in the dummy payload itself.
<payloadFactory media-type="json">
<format>[{"value" : "value1"},{"value" : "value2"},{"value" : "value3"}]</format>
<args/>
</payloadFactory>
<iterate expression="json-eval($)">
<target>
<sequence>
<property name="uri.var.value" expression="json-eval($.value)"/>
<call>
<endpoint>
<http method="get" uri-template="http://www.mocky.io/v2/5185415ba171ea3a00704eed/{uri.var.value}/address"/>
</endpoint>
</call>
</sequence>
</target>
</iterate>
来源:https://stackoverflow.com/questions/61865247/wso2-ei-esb-append-payload-from-payload-factory-to-path-parameter-in-backend-ca