【问题标题】:Transformation inside while loop- BPEL 10gwhile 循环内部的转换 - BPEL 10g
【发布时间】:2017-11-21 12:58:05
【问题描述】:

需求是从文件中读取数据并调用webservice。目标 Web 服务一次可以处理一个有效负载,但源中会有多个有效负载。 所以我使用while循环来一一处理payload。

问题:在目标服务中 EarningTypeInclusion 是可选元素,因此在源某些有效负载中该元素将存在,而在某些有效负载中该选项元素将不存在。

<thresholdRequestInterface xmlns:xs="http://www.sample.com/ns/LMSReferrals">
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
</thresholdRequest>
</thresholdRequestInterface>

如果正在使用分配活动,则当源有效负载中不存在可选元素时,将出现选择失败错误。我们正在使用 BPEL 10g,在分配活动中没有选项来抑制选择失败错误。 所以决定在 while 循环中使用转换。

使用的逻辑

从文件中读取

分配循环计数器=1

有效载荷计数(从文件中读取)

While 循环计数器

将循环计数器参数值传递给变换

将源即thresholdRequest[loopcounter]转换为目标

调用目标网络服务

递增循环计数器

结束循环;

问题是相同的数据正在获取 trsnformed。

在下面的示例中,推荐 11 数据加载了 3 次。我检查了 conter 值,它在增加,但在转换内部,相同的值正在转换。

<thresholdRequestInterface xmlns:xs="http://www.sample.com/ns/LMSReferrals">
<thresholdRequest>
<Referral>11</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
<thresholdRequest>
<Referral>12</Referral>
<thresholdValue>100</thresholdValue>
</thresholdRequest>
<thresholdRequest>
<Referral>13</Referral>
<thresholdValue>100</thresholdValue>
<EarningTypeInclusion>
<earningType>positive</earningType>
<ProvisionId>1000</ProvisionId>
</EarningTypeInclusion>
</thresholdRequest>
</thresholdRequestInterface>

来源

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.sample.com/ns/LMSReferrals" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.sample.com/ns/LMSReferrals" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="thresholdRequestInterface">
  <xs:complexType>
      <xs:sequence>
  <xs:element name="thresholdRequest" minOccurs="1" maxOccurs="unbounded">
    <xs:complexType>
      <xs:sequence>
        <xs:element  name="Referral" type="xs:string"/>
        <xs:element  name="thresholdValue" type="xs:int"/>
        <xs:element  name="EarningTypeInclusion" minOccurs="0" maxOccurs="1" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="earningType" type="xs:stirng" />
              <xs:element name="ProvisionId">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="20" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:sequence>
          </xs:complexType>
          </xs:element>

</xs:schema>

请找出源和目标的架构结构

目标

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns="http://www.sample.com/ns/LMSReferrals" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.sample.com/ns/LMSReferrals" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="thresholdRequest">
    <xs:complexType>
      <xs:sequence>
        <xs:element  name="Referral" type="xs:string"/>
        <xs:element  name="thresholdValue" type="xs:int"/>
        <xs:element  name="EarningTypeInclusion" minOccurs="0" maxOccurs="1" >
          <xs:complexType>
            <xs:sequence>
              <xs:element name="earningType" type="xs:stirng" />
              <xs:element name="ProvisionId">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="20" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
          </xs:element>
          </xs:sequence>
          </xs:complexType>
          </xs:element>
</xs:schema>

请注意,在目标 Web 服务上启用了架构验证。

【问题讨论】:

  • 嗨,您是否确保变量 thresholdRequest 实际上包含三个不同的引荐,而不是三次不同的引荐,即问题不是 read from file 步骤?

标签: xslt soa bpel


【解决方案1】:

您使用 Transform 是否有特定原因。尝试使用 ora:getElement('/thresholdRequestInterface /thresholdRequest',bpws:getVariable(loopCounter))

【讨论】:

  • 这不是答案!
猜你喜欢
  • 2015-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-24
  • 1970-01-01
相关资源
最近更新 更多