This example demonstrates how correlation sets identify the conversation between two processes.
An order entry conversation between two process (a Buyer and a Supplier) illustrates how to define a correlation set for XML mode and parameter mode. This example contains three invoke/receive/reply conversations. Since the first conversation launches the SupplyItems workflow, no correlation set is required.
These example processes are intended only to demonstrate the use of correlation sets to enable the conversation between the two processes. They do not include any decisions or error handling which would be required in any production process.
OrderItems | SupplyItems |
---|---|
The Buyer launches OrderItems and enters CustomerName and the name of an Item he might want to buy. | |
The InquireItem Invoke step requests service of the ReceiveInquiry Web Service. | |
At the InStock? step, the Supplier checks the availability of the requested item, enters a price for the item, and assigns an order number (OrderNum) to track this conversation between the two processes if the buyer decides to continue with the order. | |
The ReplyStockInfo step replies to the InquireItem step with the availability, price, and order number in the message. | |
In the Order? step, the Buyer provides a shipping address and contact name. | |
The InvOrder step invokes the ReceiveOrder Web Service with the additional order information, including OrderNum, which identifies the order. | |
At the AssignF_Corr step, we assign the CustomerName and OrderNum to a system field (F_Corr<CorrelationSetName>) that holds the value used to compare the correlation values in an incoming message. | |
The ReceiveOrder step uses an XML schema to specify the input. The correlation set specifies the value in an incoming message that identifies a specific conversation with the invoking web service. This example uses XPath queries against the XML schema to define the correlation set. | |
ReplyAckOrder acknowledges receipt of the order. The reply message uses a different XML schema. | |
FillOrder (a user step) represents the order processing. The Supplier indicates when the order was shipped. | |
InvShipNotice invokes the RecShip step in OrderItems to alert the buyer that the order has been shipped. | |
RecShip receives the appropriate shipping message via the OrderNum correlation set. | |
In the OrderComplete step, the Buyer confirms receipt of the order. RepShip replies to InvShipNotice. | |
In ShipComplete, the Supplier checks the reply message to confirm that the transaction is complete. |
Create the SupplyItems workflow
In Process Designer Workflow Properties >> General tab, identify the workflow definition.
Name: SupplyItems Subject: SupplyItems
We will save and transfer this workflow definition more than once to get the Web Services steps defined, and we might need to change the web service parameters.
Name: ReceiveInquiry Invoke: clear this check box Receive/Reply: select this check box Process Port Type: RecInquiryPort
Name: ReceiveOrder Invoke: clear this check box Receive/Reply: select this check box Process Port Type: RecOrderPort
Order entry | Acknowledgement message |
---|---|
Name: OrderEntrySchema Schema Definition : click here for text | Name: OrderAckSchema Schema Definition : click here for text |
TIP If the text does not display on separate lines in the schema definition, click Check Well Formed XML.
Name: XMLOrderField Schema: OrderEntrySchema Element: OrderEntry
From the Web Services Palette, drag a Receive step to the workflow map.
On the Properties >> General tab, enter the following:
Step name: ReceiveInquiry Partner Link: ReceiveInquiry Operation: RecInquiryOp Message Type: Parameters Operation Parameters:
Name | Type | Option |
---|---|---|
Name CustomerName ItemName | Type String String | Field Name <Create> CustomerName <Create> ItemName |
NOTE The Receive step must be the first step after the Launch step in order to launch this workflow automatically in response to a request in another workflow to invoke this Web Service.
Specify all of the following in Workflow Properties >> Data Fields.
Workflow properties |
---|
InStock (Boolean) Shipped (String) OrderNum (Integer) Price (Float) Contact (String) Address (String) OrderCompleteMsg (String) |
From the BPM Palette, drag an Activity step to the workflow map.
On the Properties >> General tab, enter the following:
Step name: InStock? Participants: Choose a specific user (you can assign it to yourself) as the participant for the step.
NOTE Do not assign F_Originator for any step in this workflow because this workflow will be launched by the system.
Parameters tab: CustomerName (read only—from the buyer) ItemName (read only—from the buyer) InStock: (read-write—entered by the supplier) Price: (read-write—entered by the supplier) OrderNum: (read-write—entered by the supplier)
TIP In this example, you will alternately add an Activity step from the BPM palette, then add a step from the Web Services palette. You might find it useful to copy these steps to MyPalette to minimize switching palettes.
From the Web Services Palette, drag a Reply step to the workflow map. On the Properties >> General tab, enter the following:
Name: ReplyStockInfo Partner Link: ReceiveInquiry Operation: RecInquiryOp Message Type: Message Operation Parameters:
Name | Type | Option |
---|---|---|
Name CustomerName ItemName InStock Price OrderNum | Type String String Boolean Float Integer | Expression CustomerName ItemName InStock Price OrderNum |
Name: AssignF_Corr
Do not specify a participant or queue for this step.
We will return to this step after we define the correlation set in the next step.
This step will receive the actual order information if the Buyer decides to continue with the order. (In our example, the Buyer always continues.)
Name: ReceiveOrder Partner Link: ReceiveOrder Operation: RecOrderOp Message Type: XML Incoming XML Data Field: XMLOrderField Schema: OrderEntrySchema Element: OrderEntry
Since the incoming message uses XML mode, we must use XPath to specify the correlation data.
Name: OrderCorrelation
Properties/Name: xpathCustomerName XPath Query String: /*[local-name()="OrderEntry"]/*[local-name()="CustomerName"]
Properties/Name: xpathOrderNum XPath Query String: /*[local-name()="OrderEntry"]/*[local-name()="OrderNum"]
On the Assignments tab, select After Completion. Under Field Assignments, enter the following:
Field name: F_CorrOrderCorrelation Expression: CustomerName + convert(OrderNum,string)
Step name: ReplyAckOrder Partner Link: ReceiveOrder Operation: RecOrderOp Message Type: Message (be sure to click Message, even if it is already selected) Schema: OrderAckSchema Element: OrderAck
"<OrderAck xmlns=""http://www.filenet.com/ns/fnpe/2004/06/po/schema/OrderAckSchema"">" + "<CustomerName>" + CustomerName +"</CustomerName>" + "<OrderNum>" + convert(OrderNum,string) + "</OrderNum>" +"</OrderAck>"
From the BPM Palette, drag an Activity step to the workflow map.
Step name: FillOrder Participants: Choose a specific user (you can assign it to yourself) as the participant for the step.
Parameters tab: OrderNum Shipped
Skip now to Create the OrderItems workflow in this document. This SupplyItems workflow definition is not complete—it needs an Invoke step to send an "order shipped" message to the other workflow, but we cannot create the Invoke step until we define a web service (a Receive step) in the other workflow.
After you complete the OrderItems workflow, add the remaining steps to the SupplyItems workflow.
Name: InvShip Invoke: Select this check box Receive/Reply: Clear this check box
Click Web Services Explorer in WSDL URL.
Still on the Partner Links tab, select: Port Type : RecStatusPort
This step then waits for a reply from the Buyer indicating that the order was received.
Name: InvShipNotice Partner Link: InvShip Operation: RecStatusOp
From the BPM Palette, drag an Activity step to the workflow map.
Step name: ShipComplete Participants: Choose a specific user (not F_Originator) as the participant for the step.
Parameters tab: All data fields
Create the OrderItems workflow
In Process Designer Workflow Properties >> General tab, identify the workflow definition.
Name: OrderItems Subject: OrderItems
Name: InquireItem Invoke: select this check box Receive/Reply: clear this check box
Click Web Services Explorer in WSDL URL.
Still on the Partner Links tab, select: Port Type : RecInquiryPort
Name: InvOrder Invoke: select this check box Receive/Reply: clear this check box
Click Web Services explorer in WSDL URL. From the list of Web Services workflow, select SupplyItems.
On the Partner Links tab, select Port Type: RecOrderPort
Step name: InquireItem Partner Link: InquireItem Operation: RecInquiryOp
Parameters: CustomerName ItemName
From the BPM Palette, drag an Activity step to the workflow map.
Name: Order? Participants: F_Originator (the Buyer who submits the request) Parameters tab: CustomerName (read only) ItemName (read only) InStock (read only) OrderNum (read only) Price (read only)
Name: InvOrder Partner Link: InvOrder Operation: RecOrderOp
Note the required parameters for placing an order and receiving an acknowledgment reply. In addition to the existing fields, the new web service requires additional data fields—Contact and Address.
Name: RecItemStatus Receive/Reply: select this check box Invoke: clear this check box Process Port Type: RecStatusPort
Name: RecShip Partner Link: RecItemStatus Operation: RecStatusOp Message Type: Parameters Operation Parameters:
Name | Type | Field Name |
---|---|---|
OrderNum Shipped | Integer String | OrderNum Shipped |
Parameter | Explanation |
---|---|
Operation Parameter Contains Correlation: OrderNum | (the value to be checked in the incoming message) |
Correlation Expression: convert(OrderNum,string) | (the data field in the current workflow that contains the value to match) |
If the data field OrderNum were a string, you could just select that field. Since it is an integer, you must convert it to a string to compare it with the value in the incoming message.
From the BPM Palette, drag an Activity step to the workflow map.
Name: OrderComplete Participants: F_Originator (the user who submits the request) Parameters tab: CustomerName (read only) ItemName (read only) OrderNum (read only) Shipped (read only)
From the Web Services Palette, drag a Reply step to the workflow map.
Step name: RepShip Partner Link: RecItemStatus Operation: RecStatusOp Message Type: Message Operation Parameter:
Name | Type | Option |
---|---|---|
Name OrderCompleteMsg | Type String | Expression CustomerName + " " + Shipped + " " + convert(systemtime(),string) |
This option ensures consistent input and output parameters for the web services (Receive functions) provided in this workflow—once you transfer this workflow definition, you cannot change the input and output parameters. It also allows any invoking process to run the latest version (or any version) of this workflow, which is essential in this situation where two workflows invoke web services in each other.
This is necessary because the first two partner links in this workflow currently invoke a specific version of the SupplyItems workflow—the WSDL URL contains a workspace identification number after the name of the workflow and before ?wsdl. We have made changes and re-transferred the SupplyItems workflow and we want to invoke the latest version.
TIP This partner link invokes the latest version of the SupplyItems workflow--the WSDL URL no longer contains the workspace identificationnumber.
Use the picture at the beginning of this example to help you navigate through the user steps involved in the order and supply processes.
You (the supplier) enter an order number, such as 1234, that will be used to track this order, and enter a price, then complete the step.
TIP If you run this workflow multiple times, you should enter a different customer name and order number each time you launch so that the correlation set can match the appropriate two-way conversations between the workflows.