[Users] Loop ForEach in Orchestra component

nguyen petals-components at ebmwebsourcing.com
Wed Mar 16 10:26:06 CET 2011


Hi,

You find here a simple example using ForEach bpel instruction for your debug.

process.wsdl file :

Code:

<?xml version="1.0"?>
<definitions name="foreachTest"
        targetNamespace="http://exemple.bpel.acoss.fr/test"
        xmlns:tns="http://exemple.bpel.acoss.fr/test"
        xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
        xmlns="http://schemas.xmlsoap.org/wsdl/"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        >

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     TYPE DEFINITION - List of types participating in this BPEL process 
     The BPEL Designer will generate default request and response types
     but you can define or import any XML Schema type and use them as part 
     of the message types.
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
    <types>
        <schema attributeFormDefault="unqualified" elementFormDefault="qualified" 
                targetNamespace="http://exemple.bpel.acoss.fr/test" 
                xmlns="http://www.w3.org/2001/XMLSchema">

            <complexType name="foreachTestRequest">
                    <sequence>
                        <element maxOccurs="unbounded" minOccurs="1" name="listbook">
							 <complexType>
							 <sequence>
							  <element maxOccurs="1" minOccurs="1" name="name" type="string"/> 
							  <element maxOccurs="1" minOccurs="1" name="nbpage" type="string"/>
							 </sequence>
							 </complexType>
				    	</element>
                    </sequence>
            </complexType>


            <complexType name="foreachTestResponse">
                    <sequence>
                        <element maxOccurs="unbounded" minOccurs="1" name="listlivre">
							 <complexType>
							 <sequence>
							  <element maxOccurs="1" minOccurs="1" name="nom" type="string"/> 
							  <element maxOccurs="1" minOccurs="1" name="nbpage" type="string"/>
							 </sequence>
							 </complexType>
				    	</element>
                    </sequence>
            </complexType>
        </schema>
    </types>


<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     MESSAGE TYPE DEFINITION - Definition of the message types used as 
     part of the port type defintions
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
    <message name="foreachTestRequestMessage">
        <part name="payload" type="tns:foreachTestRequest"/>
    </message>
    <message name="foreachTestResponseMessage">
        <part name="payload" type="tns:foreachTestResponse"/>
    </message>

    
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     PORT TYPE DEFINITION - A port type groups a set of operations into
     a logical service unit.
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    

    <!-- portType implemented by the processName BPEL process -->
    <portType name="foreachTest">
        <operation name="process">
            <input name="foreachTestRequestMessage" message="tns:foreachTestRequestMessage" />
            <output name="foreachTestResponseMessage" message="tns:foreachTestResponseMessage"/>
        </operation>
    </portType>

 
 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     BINDING DEFINITION 
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
  
 	<binding name="foreachTestBinding" type="tns:foreachTest">
    	
    	<soap:binding style="rpc"
 			transport="http://schemas.xmlsoap.org/soap/http" />
   		
   		<operation name="process">
			<soap:operation soapAction="{http://exemple.bpel.acoss.fr/test}process" />
			<input name="foreachTestRequestMessage">
    			<soap:body use="literal" 
					namespace="http://exemple.bpel.acoss.fr/test" />
    		</input>
    		<output name="foreachTestResponseMessage">
    			<soap:body use="literal"
    				namespace="http://exemple.bpel.acoss.fr/test" />
    		</output>
		</operation>
		
	</binding>
      
 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     SERVICE DEFINITION 
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
  
    <service name="foreachTest">
    	<port name="foreachTestPort" binding="tns:foreachTestBinding">
    		<soap:address location="foreachTestEndpoint"></soap:address>
    	</port>
    </service>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     PARTNER LINK TYPE DEFINITION
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    
    <plnk:partnerLinkType name="foreachTest">
        <plnk:role name="foreachTestProvider" portType="tns:foreachTest"/>
    </plnk:partnerLinkType>
    
</definitions>





process.bpel file :

Code:

<process name="foreachTest"
         targetNamespace="http://exemple.bpel.acoss.fr/test"
         suppressJoinFailure="yes"
         xmlns:tns="http://exemple.bpel.acoss.fr/test"
         xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
         xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable">

    <!-- Import the client WSDL -->
	<import location="process.wsdl" namespace="http://exemple.bpel.acoss.fr/test" 
	        importType="http://schemas.xmlsoap.org/wsdl/" />
         
    <!-- ================================================================= -->         
    <!-- PARTNERLINKS                                                      -->
    <!-- List of services participating in this BPEL process               -->
    <!-- ================================================================= -->         
    <partnerLinks>
        <!-- The 'client' role represents the requester of this service. -->
        <partnerLink name="client"
                     partnerLinkType="tns:foreachTest"
                     myRole="foreachTestProvider"
                     />
    </partnerLinks>
  
    <!-- ================================================================= -->         
    <!-- VARIABLES                                                         -->
    <!-- List of messages and XML documents used within this BPEL process  -->
    <!-- ================================================================= -->         
    <variables>
        <!-- Reference to the message passed as input during initiation -->
        <variable name="input"
                  messageType="tns:foreachTestRequestMessage"/>
                  
        <!-- 
          Reference to the message that will be returned to the requester
          -->
        <variable name="output"
                  messageType="tns:foreachTestResponseMessage"/>
    </variables>

    <!-- ================================================================= -->         
    <!-- ORCHESTRATION LOGIC                                               -->
    <!-- Set of activities coordinating the flow of messages across the    -->
    <!-- services integrated within this business process                  -->
    <!-- ================================================================= -->         
    <sequence name="main">
        
        <!-- Receive input from requester. 
             Note: This maps to operation defined in processName.wsdl 
             -->
        <receive name="receiveInput" partnerLink="client"
                 portType="tns:foreachTest"
                 operation="process" variable="input"
                 createInstance="yes"/>
        
        <!-- Generate reply to synchronous request -->
        <bpws:forEach parallel="no" counterName="Counter" name="ForEach">
            <bpws:startCounterValue>
                <![CDATA[1]]>
            </bpws:startCounterValue>
            <bpws:finalCounterValue><![CDATA[2]]></bpws:finalCounterValue>
            <bpws:scope>
                <assign validate="no" name="Assign">
            		<bpws:copy>
                        <bpws:from>
                            <![CDATA[$input.payload/tns:listbook[$Counter]/tns:name]]>
                        </bpws:from>
                        <bpws:to>
                            <![CDATA[$output.payload/tns:listlivre[$Counter]/tns:nom]]>
                        </bpws:to>
                    </bpws:copy>
                    <bpws:copy>
                        <bpws:from>
                            <![CDATA[$input.payload/tns:listbook[$Counter]/tns:nbpage]]>
                        </bpws:from>
                        <bpws:to>
                            <![CDATA[$output.payload/tns:listlivre[$Counter]/tns:nbpage]]>
                        </bpws:to>
                    </bpws:copy>
                </assign>
            </bpws:scope>
        </bpws:forEach>
        
        <reply name="replyOutput" 
               partnerLink="client"
               portType="tns:foreachTest"
               operation="process" 
               variable="output"
               />
    </sequence>
</process>






Test Data :

Code:

<payload>
      <listbook>
      	<name>Title1</name>
      	<nbpage>20</nbpage>
      </listbook>
      <listbook>
      	<name>Title2</name>
      	<nbpage>30</nbpage>
      </listbook> 
</payload>




However, the example works correctly if we replace the ForEach bloc by the sequence :

Code:

<assign validate="no" name="Assign">
            		<bpws:copy>
                        <bpws:from>
                            <![CDATA[$input.payload/tns:listbook[1]/tns:name]]>
                        </bpws:from>
                        <bpws:to>
                            <![CDATA[$output.payload/tns:listlivre[1]/tns:nom]]>
                        </bpws:to>
                    </bpws:copy>
                    <bpws:copy>
                        <bpws:from>
                            <![CDATA[$input.payload/tns:listbook[1]/tns:nbpage]]>
                        </bpws:from>
                        <bpws:to>
                            <![CDATA[$output.payload/tns:listlivre[1]/tns:nbpage]]>
                        </bpws:to>
                    </bpws:copy>
<bpws:copy>
                        <bpws:from>
                            <![CDATA[$input.payload/tns:listbook[2]/tns:name]]>
                        </bpws:from>
                        <bpws:to>
                            <![CDATA[$output.payload/tns:listlivre[2]/tns:nom]]>
                        </bpws:to>
                    </bpws:copy>
                    <bpws:copy>
                        <bpws:from>
                            <![CDATA[$input.payload/tns:listbook[2]/tns:nbpage]]>
                        </bpws:from>
                        <bpws:to>
                            <![CDATA[$output.payload/tns:listlivre[2]/tns:nbpage]]>
                        </bpws:to>
                    </bpws:copy>

                </assign>




Joyeux Noel
Best regards




-------------------- m2f --------------------

Read this forum topic online here:
http://petals.ebmwebsourcing.com/forum/viewtopic.php?p=375#375

-------------------- m2f --------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://forum-list.petalslink.org/pipermail/users/attachments/20110316/31ab7568/attachment.htm>


More information about the Users mailing list