2017-06-19 110 views
0

要求是从文件读取数据并调用webservice。目标web服务可以一次处理一个有效负载,但源中会有多个有效负载。 所以我使用while循环来逐个处理有效载荷。while while循环中的转换 - BPEL 10g

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

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

虽然有效载荷

的循环计数器< =计数

传递循环计数器参数值以变换

变换源即thresholdRequest [循环计数器]靶向

调用对象网络服务

增量循环计数器

端环;

问题是相同的数据越来越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服务已启用。

+0

嗨,你有没有保证thresholdRequest'实际持有的变量'这三个不同的推介,而不是相同的推荐三次,即问题不是'从文件读取'步骤? –

回答

0

是否有您所使用Transform.Try使用ORA一个具体原因:getElement( '/ thresholdRequestInterface/thresholdRequest' 的bpws:的getVariable(循环计数器))

+0

这不是一个答案! –