我正在使用WSO2 BPS 3.2.0,並且我有奇怪的問題將值分配給映射列表。
我有WSO2 BPEL分配給映射列表或集合
<tns:Message xmlns:tns="http://www.test.sk">
<tns:ObjectMappings>
<tns:ObjectMapping>
<tns:ObjectId/>
<tns:Id/>
</tns:ObjectMapping>
</tns:ObjectMappings>
</tns:Message>
我有輸入變量的另一集合初始化消息類型變量ObjectMappings。我遍歷輸入和處理數據。最後,我將每個處理過的ObjectId的新Id分配到上面的變量中。
<bpel:copy>
<bpel:from part="return" variable="input"><bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[Body/Object[round($Counter)]/@Id]]></bpel:query></bpel:from>
<bpel:to part="parameters" variable="ObjectMappings"><bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[ns4:ObjectMappings/ns4:ObjectMapping[round($Counter)]/ns4:ObjectId]]></bpel:query></bpel:to>
</bpel:copy>
但不幸的是它具有故障{http://docs.oasis-open.org/wsbpel/2.0/process/executable} selectionFailure結束了:沒有結果的表達式: 'ObjectMappings/ObjectMapping [圓($計數器)] /的ObjectId' 對
<Message xmlns="http://www.test.sk">
<tns:ObjectMappings xmlns="" xmlns:tns="http://www.test.sk">
<tns:ObjectMapping>
<tns:ObjectId/>
<tns:Id/>
</tns:ObjectMapping>
<tns:ObjectMapping>
<tns:ObjectId/>
<tns:Id/>
</tns:ObjectMapping>
</tns:ObjectMappings>
故障數據無可用數據。
故障在計數器值= 1時升高 當我用固定值1替換索引值輪($ Counter)時,它工作正常。即使當我添加邏輯來處理固定值的2個循環時,它也會毫無故障地結束。 所以問題是:如何將值分配到集合中?
我在分配新元素時發現了改變順序的解決方案。 –
最初我在變量的末尾添加了新元素。所以我不得不使用索引來分配值。 現在我在變量的開頭添加新元素。所以我可以通過固定索引= 1 ' <![CDATA [ns4:ObjectMappings/ns4:ObjectMapping [1]/ns4:ObjectId]]>' –
另一種解決方案可能是使用XSL轉換來分配值。在1中需要2個動作:添加新元素+賦值 –