If you use EM Test Page to test your Composites, pay attention when your XSD define that attributes must be qualified (when it uses attributeFormDefault="qualified" in the schema tag definition). When you fill the input form in EM Test Page, the generated message will not include the attribute qualifiers and attribute values will not be found by the XPath expressions in your components, as I'll show in the example below.
Suppose your XSD as the following:
When you go to the EM Test Page, the following form will be generated based on the XSD:
Go to the "XML View". See that the generated XML doesn't contain the qualifier for the two attributes.
Run the process and check the execution audit trail. See that the attributes values was not found.
Go back to the "XML View" and add the qualifiers manually.
Run the process again and check the execution audit trail. See that the attributes values was found now.
This behavior may take a lot of time until you can identify what is happening.
My suggestion: always use SoapUI to test your SOA Suite Composite Projects. With SoapUI is easy to define your test cases, you can save them to run multiple times and the input messages are generated much more closely to the XSD definition.
To download this sample project and do your tests, click here.
Sunday, February 13, 2011
Sunday, January 23, 2011
Implementing Correlation in BPM 11gR1 using BPEL
As far as I know, Oracle BPM 11g doesn't have an easy way to implement correlation sets and receive asynchronous messages in the middle of the process using some business information. But as Oracle BPM is in the top of Oracle SOA Suite infrastructure, we can use BPEL to achieve this behaviour. Using BPMN, Mediator and BPEL components together in a composite, we can expose 2 interfaces, one for start the business (BPMN) process and other to expose the asynchronous (BPEL) intermediate message, as I'll show below.
First of all, create a new BPM Project with a BPMN component.
In the "Create BPMN Process" dialog, import an external schema with data definition and define the input and output arguments.
Double click in the "Start" activity and create a new "Data Association".
Create a new "Business Process" variable using the same inputArg data type.
Copy the inputArg data to the new variable created.
Go back to the composite and add a new BPEL component. Select "Based on WSDL" template and define an asynchronous operation using the same external schema.
In the "Request" definition, select an element that has the unique business identifier that will be used to correlate the inbound intermediate operation.
In the "Callback" definition, select an element that define the same message that will be received in the middle of the process.
Uncheck the option "Expose as a SOAP service".
Open the WSDL generated for the BPEL process. Create a new one way operation in the inbound port type to receive the intermediate message in the BPEL process. Use the same callback message that will be returned by the BPEL process.
Open the BPEL process and create a new correlation set in the receiveInput activity.
Initialize the correlation set with the unique business identifier received.
Set the column "Initiate" to "Yes" (To get more informations about how to configure Correlation Sets in BPEL, click here).
Create a new Receive activity to receive the intermediate operation.
Select the intermediate operation and generate a new variable to receive the intermediate message.
Select the correlation set created previously.
Edit the correlation set to match the unique business identifier received in the intermediate message.
Add an Assign activity to the BPEL process to copy the message received in the intermediate operation to the output variable.
The BPEL process will looks like as the image below.
Go back to the composite, add a new Mediator component and select "Interface Definition from WSDL" template.
Define an one-way operation using the same external schema. In the "Request" definition, select the element that define the message that will be received in the middle of the process.
Connect the Mediator to the BPEL component, using the intermediateOperation of the BPEL component as the Target Operation.
Open the Mediator editor and create an Assign to route the received message. Keep the other configurations empty.
Go back to the BPMN diagram, add a Throw event after the Start event. In the "Implementation" tab, select "Message" as "Implementation Type" and "Service Call" in the "Implementation" properties.
Select the BPEL component interface as the service to be called and create a new "Data Association".
Copy the unique business identifier from the business process variable to the service input variable.
Add a new Catch event after the Throw event created. In the "Implementation" tab, select "Message" as "Implementation Type" and "Continues" as "Conversation" option. Select the throw event as "Initiator Node" and create a new "Data Association".
Create a new "Business Process" variable using the same data type as the intermediate operation returns. Copy the data received to the new variable created.
The final BPMN process will looks like this.
And the composite will looks like this.
Deploy the composite to the server and create a new instance of the business process calling the BPMN process interface.
See the execution flow trace.
Check that the BPMN process is waiting in the catch activity.
And the BPEL process is waiting in the receiveIntermediate activity.
Back to the Enterprise Manager, invoke the intermediateOperation through the Mediator interface.
Use the same unique business identifier used to initiate the business process.
See the execution flow trace again. Check that a new instance of the Mediator component was created, but the message was delivered to the BPEL instance created before (through correlation set).
Check that the BPEL instance finished, sending the received message to the caller process.
Check that the BPMN process received the callback message and finished successfully.
This idea can be extended to allow multiple intermediate messages being received during the business process execution. If all intermediate information to be received uses the same message, you can reuse the BPEL process, otherwise you can create additional BPEL components to receive different messages. Other improvement you can do is use the Mediator component in front of all the other components to expose a single interface (WSDL) and route each operation to the appropriate internal composite component.
To download this sample project, click here.
First of all, create a new BPM Project with a BPMN component.
In the "Create BPMN Process" dialog, import an external schema with data definition and define the input and output arguments.
Double click in the "Start" activity and create a new "Data Association".
Create a new "Business Process" variable using the same inputArg data type.
Copy the inputArg data to the new variable created.
Go back to the composite and add a new BPEL component. Select "Based on WSDL" template and define an asynchronous operation using the same external schema.
In the "Request" definition, select an element that has the unique business identifier that will be used to correlate the inbound intermediate operation.
In the "Callback" definition, select an element that define the same message that will be received in the middle of the process.
Uncheck the option "Expose as a SOAP service".
Open the WSDL generated for the BPEL process. Create a new one way operation in the inbound port type to receive the intermediate message in the BPEL process. Use the same callback message that will be returned by the BPEL process.
Open the BPEL process and create a new correlation set in the receiveInput activity.
Initialize the correlation set with the unique business identifier received.
Set the column "Initiate" to "Yes" (To get more informations about how to configure Correlation Sets in BPEL, click here).
Create a new Receive activity to receive the intermediate operation.
Select the intermediate operation and generate a new variable to receive the intermediate message.
Select the correlation set created previously.
Edit the correlation set to match the unique business identifier received in the intermediate message.
Add an Assign activity to the BPEL process to copy the message received in the intermediate operation to the output variable.
The BPEL process will looks like as the image below.
Go back to the composite, add a new Mediator component and select "Interface Definition from WSDL" template.
Define an one-way operation using the same external schema. In the "Request" definition, select the element that define the message that will be received in the middle of the process.
Connect the Mediator to the BPEL component, using the intermediateOperation of the BPEL component as the Target Operation.
Open the Mediator editor and create an Assign to route the received message. Keep the other configurations empty.
Go back to the BPMN diagram, add a Throw event after the Start event. In the "Implementation" tab, select "Message" as "Implementation Type" and "Service Call" in the "Implementation" properties.
Select the BPEL component interface as the service to be called and create a new "Data Association".
Copy the unique business identifier from the business process variable to the service input variable.
Add a new Catch event after the Throw event created. In the "Implementation" tab, select "Message" as "Implementation Type" and "Continues" as "Conversation" option. Select the throw event as "Initiator Node" and create a new "Data Association".
Create a new "Business Process" variable using the same data type as the intermediate operation returns. Copy the data received to the new variable created.
The final BPMN process will looks like this.
And the composite will looks like this.
Deploy the composite to the server and create a new instance of the business process calling the BPMN process interface.
See the execution flow trace.
Check that the BPMN process is waiting in the catch activity.
And the BPEL process is waiting in the receiveIntermediate activity.
Back to the Enterprise Manager, invoke the intermediateOperation through the Mediator interface.
Use the same unique business identifier used to initiate the business process.
See the execution flow trace again. Check that a new instance of the Mediator component was created, but the message was delivered to the BPEL instance created before (through correlation set).
Check that the BPEL instance finished, sending the received message to the caller process.
This idea can be extended to allow multiple intermediate messages being received during the business process execution. If all intermediate information to be received uses the same message, you can reuse the BPEL process, otherwise you can create additional BPEL components to receive different messages. Other improvement you can do is use the Mediator component in front of all the other components to expose a single interface (WSDL) and route each operation to the appropriate internal composite component.
To download this sample project, click here.
Subscribe to:
Posts (Atom)