Swordfish Documentation: Designing BPEL Eclipse BPEL Designer
Creating BPEL Process Skeleton
- Select File > New Wizard > BPEL 2.0 > BPEL project to create a new BPEL project and name it, FlightBooking.
- Next, create a BPEL file by selecting New Wizard >BPEL 2.0 >New BPEL Process File. In the BPEL file wizard window enter:
- BPEL Process Name: FlightBookingProcess
- Namespace: http://www.eclipse.org/swordfish/samples/FlightBooking
- Template: Empty BPEL process
- In the next wizard window set the option to choose BPEL project I've created before.
- Open the newly created FlightBookingProcess.bpel with BPEL Designer by double clicking it. You can now see a visual representation of an empty BPEL process as shown in this figure.
- Expand the BPEL elements palette by clicking the arrow icon highlighted in this figure:
- Using the Element Palette, create an initial BPEL Process Skeleton as displayed in this image:
Setting Up BPEL WSIL Browser
To create a Partner Link to an external Web service and expose the BPEL process as a Web service we need a set of corresponding WSDL files. In the current tutorial, those files can be accessed from the Swordfish Registry.
- Start Swordfish Service Registry, [download]) and install the 3 WSDL files:FlightBooking.wsdl, FlightReservation.wsdl, and PaymentProcessing.wsdl. The Service Registry automatically provides a WSIL file for the installed WSDLs. The default URL is http://localhost:9001/registry/wsil, as shown in this figure.
- In order to access and import the above mentioned WSDL files initialize BPEL WSIL Browser. To do this select Preference > BPEL > WSIL Brower and set "Document URL" field as http://localhost:9001/registry/wsil.
- Click OK.
- IMPORTANT: Service Registry should be up and running in the next phase, that is, the design and process execution phase.
Creating Partner Links
In the newly created process diagram we have one receive-type element (with same name "Receive") and two invoke-type elements ("processReservation" and "paimentProcessing"). For the Receive-type element we need InBound endpoints and for the invoke-type we need to create OutBound endpoints. To create Partner Links we need to import the corresponding WSDL file to the BPEL process.
Creating Receive-InBound Partner Link
- Click on the Receive element in the BPEL diagram. Open theProperties view and click the Details tab. You should see an empty Partner Link and Operation Fields item. Expand the Partner Link drop down list and choose the Create Global Partner Link item:
- In the New Partner Link window, type FlightBooking.
- In the next window, the option Choose Partner Link Type will be empty by default. To see the available types we need to import the corresponding WSDL files. Click on Add WSDL.
- In the Browse for a WSDL to Import check the WSIL button. If your Swordfish Registry is up and running, and the BPEL WSIL Browser is set up correctly, you should see the Inspection tree including all 3 WSDL files. For this step you need to click on 'FlightBooking.wsdl' and click OK.
- Repeat the previous step for the 'FlightReservation.wsdl' and 'PaymentProcessing.wsdl' files.
- Now your New Partner Link window should look similar to the image shown next.
- Click the 'FlightBooking' item in the Matches area and click OK.
- In the next window set Partner Link Type Name with the same value as Partner Link Name: 'FlightBooking'.
- Click OK to go to the next step of partner link type creation window.
- In the next window, enter 'InBound' for the Role Name field and select FlightBooking port type from list below(see image).
- Click Finish.
- Leave the options in theSet Namespace Prefix window fields as it is.
- After you finish creating the partner link go back to BPEL diagram and check your changes:
- The new Partner Link 'FlightBooking' is now visible in the BPEL process sidebar
- In the properties pane 'Receive' element Partner Link should become initialized with just the created partner link name.
- In the properties pane for 'Receive' element, Operation link is still empty.
- We still need to set Operation field for 'Receive' element. The easiest way do to this is to click on the flightBooking operation icon within the Quick Pick element tree. Now, you can also see that the new process variable 'FlightBookingRequest' that has been automatically created and assigned to a current partner link:
Creating flightReservation OutBound Partner Link
Select the flightReservation element in the BPEL Designer to edit its properties and repeat the same set of steps as described in the previous section.
- Partner Link Name and Partner Link Type Name should be FlightReservation
- Partner Link Role Name should be set to 'OutBound'
- Operation name for FlightReservation partner link is reserveFlight.
Creating paymentProcessing OutBoing Partner Link
Select paymentProcessing element in BPEL designer to edit its' properties and make same set of action as above.
- Partner Link Name and Partner Link Type Name should be 'PaymentProcessing'
- The Partner Link Type Role Name should be set to 'OutBound'
- The operation name for PaymentProcessing partner link is paymentProcessing
Creating Reply Partner Link
Select paymentProcessing element in BPEL designer to edit its' properties. No Partner Link creating needed this time, we will use existing FlightBooking partner link. Set Properties pane values as on image below.
NOTE: After you set the operation value, a new variable 'FlightBookingResponse' should be automatically created.
Assign-type elements initialization
Assign elements using the transit data from one BPEL logic element to the next.
In our case we have the following scenario:
- pass initial request data from Receive element to flightRecervation element (Assign)
- pass flightReservation element's response to paymentProcessing element (Assign1)
- pass paymentData element's response to Rely element (Assign2)
Initialization of the first Assign Element(element name: 'Assign')
- Click on the Assign element on the top of the BPEL diagram and open Properties >Details tab. It will be empty by default.
- click on New to create a new assign statement. This will populate From and To variables trees.
- Expand the 'FlightBookingRequest' item from From list (left side) and select parameters: bookFlight > flightData: FlightData item.
- Expand the 'FlightReservationRequest' item in theTo list (right side) and select parameters: reserveFlight > flightData: FlightData item
- We have now just created a Variable to Variable assignment. It passes the initial request to the FlightReservation service. But FlightReservationRequest variable need additional initialization before assignment execution can be completed. The BPEL Designer is responsible for generating this initialization part automatically. However, there are some prerequisite steps to be done before this can work.
- Click on some empty area in the process diagram pane. You should then see this pop-up:
- Click OK and go back to Assign Properties >Details tab. You should see that there is a new "Fixed Value to Variable" assignment.
- This statement assigns the XML-string to FlightReservationRequest before "Variable to Variable" assign statement execution starts. Wee need this to create a well-formed request to the Flight Reservation service. Now your first assign element initialization is done!
Initialization of the second Assign Element(element name: 'Assign1')
The same set of actions as for first assign elements must be performed but with different variables:
- From FlightBookingRequest->paymentData
- To PaymentProcessingRequest->paymentData
- IMPORTANT: don't forget about additional initialization using 'Fixed Value to Variable' statement auto generation
Initialization of the third Assign Element(element name: 'Assign2')
Now you need to do the same set of actions as for first assign elements. However, once again the variable are different:
- From PaymentProcessing->response
- To FlightBookingResponse->response
- IMPORTANT: Do not forget about the additional initialization using the 'Fixed Value to Variable' statement auto generation function.
NOTE: You can now use this process.
The resulting artifacts are:
Now those files ready for packaging and deployment.