循环内部转换 - BPEL 10g

时间:2017-06-19 10:40:47

标签: xslt soa bpel

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

问题:在目标服务中,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>

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

使用

逻辑

从文件中读取

指定循环计数器= 1

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

while循环计数器&lt; =有效负载计数

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

将源转换为thresholdRequest [loopcounter]到target

调用目标Web服务

增量循环计数器

结束循环;

问题是相同的数据正在变形。

在下面的示例中,引用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>

请注意,目标网络服务已启用架构验证。

1 个答案:

答案 0 :(得分:0)

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

相关问题