【问题标题】:WSO2 BPEL assign to mapping list or collectionWSO2 BPEL 分配给映射列表或集合
【发布时间】:2015-10-20 07:52:20
【问题描述】:

我正在使用 WSO2 BPS 3.2.0,但在为映射列表赋值时遇到了奇怪的问题。
我有用

初始化的消息类型变量 ObjectMappings
<tns:Message xmlns:tns="http://www.test.sk">
<tns:ObjectMappings>
  <tns:ObjectMapping>
    <tns:ObjectId/>
    <tns:Id/>
  </tns:ObjectMapping>
</tns:ObjectMappings>
</tns:Message>

我在输入变量中有另一个集合。我遍历输入并处理数据。最后,我为每个已处理的 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: No results for expression: 'ObjectMappings/ObjectMapping[round($Counter)]/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 替换索引值 round($Counter) 时,它工作正常。即使我添加逻辑来处理具有固定值的 2 个循环,它最终也不会出错。 所以问题是:如何将值分配到集合中?

【问题讨论】:

  • 我在分配新元素时找到了更改顺序的解决方案。
  • 最初我在变量末尾添加了新元素。所以我不得不使用索引来赋值。现在我在变量的开头添加新元素。所以我可以通过固定索引 = 1 &lt;bpel:to part="parameters" variable="ObjectMappings"&gt;&lt;bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0"&gt; &lt;![CDATA[ns4:ObjectMappings/ns4:ObjectMapping[1]/ns4:ObjectId]]&gt;&lt;/bpel:query&gt;&lt;/bpel:to&gt; 赋值
  • 另一种解决方案是使用 XSL 转换来分配值。它采取 2 合 1 的操作:添加新元素 + 赋值

标签: wso2 variable-assignment bpel


【解决方案1】:

我在分配新元素时找到了更改顺序的解决方案。
最初我在变量末尾添加了新元素

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多