2017-06-19 108 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

這不是一個答案! –