flowNアクティビティ作成時の処理内容
次のコードは、flowNアクティビティを使用して任意の数のホテルの情報を参照する.bpel
ファイルを示しています。
次の例は順序名を示しています。
<sequence name="main"> <!-- Received input from requester. Note: This maps to operation defined in NflowHotels.wsdl The requester sends a set of hotels names wrapped into the "inputVariable" -->
次のアクションを実行します。receiveアクティビティは、クライアント・パートナ・リンクをコールし、flowNアクティビティがN
の数を定義してホテル情報を参照するために必要な情報を取得します。次に例を示します。
<receive name="receiveInput" partnerLink="client" portType="client:NflowHotels" operation="initiate" variable="inputVariable" createInstance="yes"/> <!-- The 'count()' Xpath function is used to get the number of hotelName noded passed in. An intermediate variable called "NbParallelFlow" is used to store the number of N flows being executed --> <assign name="getHotelsN"> <copy> <from expression="count($InputVariable.payload/client:HotelName);"/> <to variable="NbParallelFlow"/> </copy> </assign> <!-- Initiating the FlowN activity The N value is initialized with the value stored in the "NbParallelFlow" variable The variable call "Index" is defined as the index variable NOTE: Both "NbParallelFlow" and "Index" variables have to be declared -->
次に、flowNアクティビティが開始されます。flowNのアクティビティの名前を定義した後、N
をinputVariable
(ホテル・エントリの数)の値として定義します。また、このアクティビティは、索引変数としてindex
を割り当てます。次に例を示します。
<bpelx:flowN
name="FlowN" N="bpws:getVariableData('NbParallelFlow')
indexVariable="Index'>
<sequence name="Sequence_1">
<!-- Fetching each hotelName by indexing the "inputVariable" with the
"Index" variable.
Note the usage of the "concat()" Xpath function to create the
expression accessing the array element.
-->
次の例に示すコピー・ルールで索引変数を使用し、複数のホテル・エントリを1つのリストに連結します。
<assign name="setHotelId"> <copy> <from expression= "bpws:getVariableData('inputVariable','payload',concat('/client:Nflo wHotelsProcessRequest/client:ListOfHotels/client:HotelName[', bpws:getVariableData('Index'),']'))"/> <to variable="InvokeHotelDetailInputVariable" part="payload" query="/ns2:hotelInfoRequest/ns2:id"/> </copy> </assign>
このホテル情報を使用して、invokeアクティビティは、Webサービスから各ホテルの詳細情報を参照します。次に例を示します。
<!-- For each hotel, invoke the web service giving detailed information on the hotel --> <invoke name="InvokeHotelDetail" partnerLink="getHotelDetail" portType="ns2:getHotelDetail" operation="process" inputVariable="InvokeHotelDetailInputVariable" outputVariable="InvokeHotelDetailOutputVariable"/> </sequence> </bpelx:flowN>
最後に、このBPELプロセスは、各ホテルの詳細情報をクライアント・パートナ・リンクに送信します。次に例を示します。
<invoke name="callbackClient" partnerLink="client" portType="client:NflowHotelsCallback" operation="onResult" inputVariable="outputVariable"/> </sequence> </sequence>