在wso2 ESB中使用迭代中介
我的输入请求如下:在wso2 ESB中使用迭代中介,wso2,wso2esb,esb,Wso2,Wso2esb,Esb,我的输入请求如下: <body> <p:UpdateID xmlns:p="http://tempuri.org"> <!--Exactly 1 occurrence--> <xs:newid xmlns:xs="http://tempuri.org">NewID</xs:newid> <!--1 or more occurrences--> <xs:oldid xmlns:xs="http://te
<body>
<p:UpdateID xmlns:p="http://tempuri.org">
<!--Exactly 1 occurrence-->
<xs:newid xmlns:xs="http://tempuri.org">NewID</xs:newid>
<!--1 or more occurrences-->
<xs:oldid xmlns:xs="http://tempuri.org">OldID_001</xs:oldid>
<xs:oldid xmlns:xs="http://tempuri.org">OldID_002</xs:oldid>
</p:UpdateID>
</body>
纽伊德
OldID_001
OldID_002
我已经编写了一个代理服务,但我不是:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="UpdateID" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<iterate xmlns:xs="http://tempuri.org" id="Iterate1" expression="count(//xs:oldid)">
<target>
<sequence>
<property name="newid" expression="//xs:newid" scope="default" type="STRING"/>
<property name="oldid" expression="//xs:oldid" scope="default" type="STRING"/>
<payloadFactory>
<format>
<p:UpdateID xmlns:p="http://tempuri.org">
<xs:newid>$1</xs:newid>
<xs:oldid>$2</xs:oldid>
</p:UpdateID>
</format>
<args>
<arg expression="get-property('newid')"/>
<arg expression="get-property('oldid')"/>
</args>
</payloadFactory>
<send>
<endpoint key="UpdateEP"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<publishWSDL uri="http://xyz:9764/services/Update_DataService?wsdl"/>
<description></description>
</proxy>
$1
$2
现在我的问题是如何获得oldid的计数,以便从0迭代到oldid的计数,类似于for循环。
其次,我如何将oldid值逐个分配给有效负载。
请帮忙。在这种情况下,提前感谢 < P>。它允许您在JavaScript或Python中编写脚本来执行所需的操作。它允许您用JavaScript或Python编写脚本来执行所需的操作。您可以将迭代表达式更改为expression=“//xs:oldid”,它将迭代到可用oldid元素的数量。然后您可以从迭代器中获取newid值的赋值,因为只有一个newid元素。我已经用这些更改更新了您的代理配置
<proxy xmlns="http://ws.apache.org/ns/synapse" name="UpdateID" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="newid" expression="//xs:newid" scope="default" type="STRING" xmlns:xs="http://tempuri.org"/>
<iterate xmlns:xs="http://tempuri.org" id="Iterate1" expression="//xs:oldid">
<target>
<sequence>
<property name="oldid" expression="//xs:oldid" scope="default" type="STRING"/>
<payloadFactory>
<format>
<p:UpdateID xmlns:p="http://tempuri.org">
<xs:newid>$1</xs:newid>
<xs:oldid>$2</xs:oldid>
</p:UpdateID>
</format>
<args>
<arg expression="get-property('newid')"/>
<arg expression="get-property('oldid')"/>
</args>
</payloadFactory>
<send>
<endpoint key="UpdateEP"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<publishWSDL uri="http://xyz:9764/services/Update_DataService?wsdl"/>
<description></description>
</proxy>
$1
$2
您可以将迭代表达式更改为expression=“//xs:oldid”,它将迭代到可用oldid元素的数量。然后您可以从迭代器中获取newid值的赋值,因为只有一个newid元素。我已经用这些更改更新了您的代理配置
<proxy xmlns="http://ws.apache.org/ns/synapse" name="UpdateID" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="newid" expression="//xs:newid" scope="default" type="STRING" xmlns:xs="http://tempuri.org"/>
<iterate xmlns:xs="http://tempuri.org" id="Iterate1" expression="//xs:oldid">
<target>
<sequence>
<property name="oldid" expression="//xs:oldid" scope="default" type="STRING"/>
<payloadFactory>
<format>
<p:UpdateID xmlns:p="http://tempuri.org">
<xs:newid>$1</xs:newid>
<xs:oldid>$2</xs:oldid>
</p:UpdateID>
</format>
<args>
<arg expression="get-property('newid')"/>
<arg expression="get-property('oldid')"/>
</args>
</payloadFactory>
<send>
<endpoint key="UpdateEP"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<publishWSDL uri="http://xyz:9764/services/Update_DataService?wsdl"/>
<description></description>
</proxy>
$1
$2