WSO2 EI/ESB: Append payload from Payload Factory to Path Parameter in backend call

僤鯓⒐⒋嵵緔 提交于 2020-06-01 07:41:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!