2015-10-20 66 views
0

我正在使用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個循環時,它也會毫無故障地結束。 所以問題是:如何將值分配到集合中?

+0

我在分配新元素時發現了改變順序的解決方案。 –

+0

最初我在變量的末尾添加了新元素。所以我不得不使用索引來分配值。 現在我在變量的開頭添加新元素。所以我可以通過固定索引= 1 ' <![CDATA [ns4:ObjectMappings/ns4:ObjectMapping [1]/ns4:ObjectId]]>' –

+0

另一種解決方案可能是使用XSL轉換來分配值。在1中需要2個動作:添加新元素+賦值 –

回答

0

我在分配新元素時找到了更改順序的解決方案。
最初我添加新元件在可變

<tns:ObjectMappings xmlns="" xmlns:tns="http://www.test.sk"> <tns:ObjectMapping> <tns:ObjectId>1</tns:ObjectId> <tns:Id>10</tns:Id> </tns:ObjectMapping> <tns:ObjectMapping> <tns:ObjectId/> <tns:Id/> </tns:ObjectMapping> </tns:ObjectMappings>

的端部因此,我不得不使用索引來分配值。 現在我在可變

<tns:ObjectMappings xmlns="" xmlns:tns="http://www.test.sk"> <tns:ObjectMapping> <tns:ObjectId/> <tns:Id/> </tns:ObjectMapping> <tns:ObjectMapping> <tns:ObjectId>1</tns:ObjectId> <tns:Id>10</tns:Id> </tns:ObjectMapping> </tns:ObjectMappings>

的開始添加新的元件現在我可以由固定指數= 1

我發現溶液在分配新元件時改變順序分配值。
最初我在變量的末尾添加了新元素。所以我不得不使用索引來分配值。 現在我在變量的開頭添加新元素。所以我可以通過固定的索引值賦值= 1

<bpel:to part="parameters" variable="ObjectMappings"><bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"> 
<![CDATA[ns4:ObjectMappings/ns4:ObjectMapping[1]/ns4:ObjectId]]></bpel:query> 
</bpel:to>