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.