A BPEL process addresses this issue with correlation sets, each of which is a list of properties whose values are expected to remain constant throughout a process or throughout a specific scope, even as data is transmitted to and from partner services.
For purposes of an example, here is a process that records the purchase orders of custumers, so it needs to identify each specific custumer-order. This is the diagram of the whole process:The following steps describe how to identify a process using correlation sets:
- First, the following namespace into your WSDL file:
xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/varprop" - Create the property to be used to identify your process. In this example we will use 2 values to identify the process or the PO of the customer, so add the following at the end of your WSDL.
<bpws:property name="customerID" type="p:string" />
<bpws:property name="orderNumber" type="p:string" /> - The process will start after answer the first request, for example, when the customer puts a new Purchase Order, the process will return the PO number, then the BPEL process will identify an specific process using the CustomerID and the OrderNumer. To do the previous logic, add the following to your WSDL. This is telling that the CID and Order will be used as a combined key.
<!-- sendResponse -->
<bpws:propertyAlias propertyName="tns:customerID" messageType="tns:sendPOResponse" part="confirmation">
<bpws:query><![CDATA[/tns:CID]]></bpws:query>
</bpws:propertyAlias>
<bpws:propertyAlias propertyName="tns:orderNumber" messageType="tns:sendPOResponse" part="confirmation">
<bpws:query><![CDATA[/tns:Order]]></bpws:query>
</bpws:propertyAlias> - Also, for each subsequent message sent to the BPEL process we will require that the user sends the CID and Order, to do that, define that while requesting a operation those values must be sent. Example:
<!-- QUERY Request -->
<bpws:propertyAlias propertyName="tns:customerID" messageType="tns:queryPORequest" part="query">
<bpws:query><![CDATA[/tns:CID]]></bpws:query>
</bpws:propertyAlias>
<bpws:propertyAlias propertyName="tns:orderNumber" messageType="tns:queryPORequest" part="query">
<bpws:query><![CDATA[/tns:Order]]></bpws:query>
</bpws:propertyAlias> - Now, define the correlationSets into your BPEL process
<bpws:correlationSets>
<bpws:correlationSet name="PurchaseOrder" properties="tns:customerID tns:orderNumber"/>
</bpws:correlationSets> - As previously mentioned, the process will start when answering to the first request, so we define that inside the first reply activity:
<bpws:reply name="replyOutput" operation="sendPO" partnerLink="POLink" portType="tns:purchaseOrderProcess" variable="output">
<bpws:correlations>
<bpws:correlation initiate="yes" set="PurchaseOrder"/>
</bpws:correlations>
</bpws:reply>
- And in subsequent requests, the correlation only will be used, not initiated again. For example, while querying the process:
<bpws:onMessage operation="queryPO" partnerLink="POLink" portType="tns:purchaseOrderProcess" variable="queryInput">
<bpws:correlations>
<bpws:correlation initiate="no" set="PurchaseOrder"/>
</bpws:correlations>
Download the example from here.