站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Netbeans 专题Understanding the Travel Reservation Service

Understanding the Travel Reservation Service

摘要: Understanding the Travel Reservation Service

Contents


Overview

The Travel Reservation Service is a sample business process provided with NetBeans Enterprise Pack 5.5.

The Travel Reservation Service acts as a logical aggregator of other services and is based on business logic typical of travel reservation systems as described below.

For more information about working with the NetBeans IDE, see the Docs & Support page on the NetBeans web site.


Prerequisites

This tutorial assumes that you have some basic knowledge of, or programming experience with, the Java language and platform and the NetBeans IDE.

System Requirements

This tutorial assumes that your system meets the requirements specified in the System Requirements section of the NetBeans Enterprise Pack 5.5 Release Notes.

Software Needed for the Tutorial

Before you begin, install the following software on your computer:

  • NetBeans IDE 5.5 with NetBeans Enterprise Pack 5.5 (download)

top


Configuring the Tutorial Environment

The JBI Runtime and the Sun Java System Application Server must be properly configured and running before you can deploy the application.

First, perform the following steps to confirm that the JBI server is started:

  1. Open the Runtime window.
  2. Expand the Servers node.
  3. If the node already contains a Sun Java Application Server, skip ahead to step 5.
  4. If the node does not contain a Sun Java Application Server, follow these steps:
    1. Right-click the Servers node and choose Add Server.
    2. In the Add Server Instance dialog box choose Sun Java Application Server.
    3. Click Next.
    4. In the Platform Location specify C:\Sun\AppServer. This is the default Application Server installation path as set by the Enterprise Pack installer. Select Register Local Default Domain.
    5. Click Next.
    6. Supply this username and password for the Application Server: admin/adminadmin. This is the default username and password set by the installer.
    7. Click Finish
  5. Right-click the Sun Java System Application Server node and choose Start. If the Start option is not available and there is a green triangle next to the Sun Java System Application Server node, your server is already running.

    Application Server Running

top


Creating a New Project with the Travel Reservation Service Sample Project

To create a new project using the Travel Reservation Service Sample:

  1. From the IDE's main menu, choose File > New Project.
  2. Under Categories select Samples > Service Oriented Architecture.
  3. Under Projects, select Travel Reservation Service.
  4. Click Next.

    New Project

  5. Type the project name and location of your choice, or accept the defaults.
  6. Click Finish.
  7. The Projects window now contains two project nodes: one for TravelReservationService, a BPEL module and one for TravelReservationServiceApplication, a Composite Application project.

    Two Projects

Demo
View Demo

Partner Services

The Travel Reservation Service communicates with its partner services via their public interfaces. These interfaces are defined in partner-specific WSDL files.
The IDE includes a bundled EJB project called ReservationPartnerServices. The ReservationPartnerServices project contains a basic EJB and JMS based implementation of the three partner services. These partner services are Hotel Reservation Service, Vehicle Reservation Service and Airline Reservation Service.
These partner web services must be deployed to the bundled Sun Java Application Server before you can test run the Travel Reservation Service process.

This implementation is only meant to serve as a test harness for the Travel Reservation Service process. The implementation of the partner services should not be of any interest to the BPEL developer. They are merely prerequisites to the testability of the Travel Reservation Service.

Follow these steps to open and deploy the ReservationPartnerServices:

  1. Choose File > Open Project from the main menu.
  2. Use the Open Project wizard to navigate to the TravelReservationService directory.
    The directory that contains the TravelReservationService also contains the bundled ReservationPartnerServices.
  3. Select the ReservationPartnerServices and click the Open Project Folder button.

    Open Partner Services Project

  4. Right-click the ReservationPartnerServices and choose Deploy Project. This deploys the ReservationPartnerServices.
  5. Verify that the ReservationPartnerServices application was successfully deployed by performing the following steps:
    • Switch to the Runtime window and expand the Sun Java System Application Server node.
    • Expand the Applications node and then expand the EJB Modules node.

      Partner Services Deployed

Demo
View Demo

top


Deploying the BPEL Project to the Application Server

A BPEL project is not directly deployable. You must add a BPEL project, as a JBI module, to a Composite Application project. You can then deploy the Composite Application project.  Deploying the project makes the service assembly available to the application server, thus allowing its service units to be run.

  1. Right-click the TravelReservationServiceApplication deployment project node in the Projects window, and choose Add JBI Module.
    The Select Project wizard comes up.
  2. Select TravelReservationService from the Select Project wizard.

    Select TravelReservationService

  3. Click the Add Project Jar Files button.
  4. In the Projects window, expand TravelReservationServiceApplication > JBI Modules.
  5. Notice that TravelReservationService.jar node is added.

    TravelReservationService.jar is added

  6. Right-click the TravelReservationServiceApplication project node, and choose Deploy Project from the pop-up menu.
  7. In the Warning dialog box, make sure the Sun Java Application Server 9 is selected and click OK.
  8. The deployment succeeded if you see the following message in the Output window:

    Build Successful

Demo
View Demo

top


Performing a Test Run of the Travel Reservation Service Process

The Test run feature enables business process developers to test run their processes. BPEL processes are deployed to the BPEL runtime, which manages the process lifecycle. A BPEL process starts with a receive or pick activity responsible for initiating the process.

A BPEL process is also a web service. Like any web service, a BPEL process has a companion WSDL file that describes its public interface. This interface in turn describes the operations and messages that clients can target in order to create the process instance. Upon the receipt of a message targeted at one of these receive activities, the BPEL runtime will create a BPEL process instance and hand the message to the process instance for processing.

For example, in the case of the TravelReservationService.wsdl there is an operation called buildItinerary. This is the operation that TravelReservationService clients will call in order to initiate a conversation with the TravelReservationService.

<portType name="TravelReservationPortType">
<operation name="buildItinerary">
      <input message="tns:ItineraryIn"/>
      <output message="tns:ItineraryOut"/>
      <fault name="itineraryProblem" message="tns:ItineraryFault"/>
</operation>
</portType>

Thus, to test a BPEL process, you must send the BPEL runtime a message targeted at one of the process receive activities.

This version of the BPEL Designer contains features to make this testing a point-and-click experience. Specifically, with the TravelReservationService sample project, you can send buildItinerary requests to the deployed TravelReservationService.

Test Run Procedure

To test run the TravelReservationService:

  1. Expand the TravelReservationServiceApplication node. It has a sub-node called Test.
  2. Expand the Test node. There will be 4 sub-nodes.
    • HasNoReservations - a test itinerary with no reservations
    • HasAirline - a test itinerary with a pre-existing airline reservation
    • HasVehicle - a test itinerary with pre-existing airline and vehicle reservations
    • HasHotel - a test itinerary with a pre-existing airline, vehicle and hotel reservations

    These test nodes are actually XML files that contain SOAP message data. Each one represents a different case that can be used to test the TravelReservationService in order to exercise the process in slightly different ways.

  3. Right-click the HasNoReservations node and choose Test from the pop-up menu. Once you select the Test action, the IDE sends the HasNoReservations SOAP message to the BPEL runtime. The IDE will indicate if the test is successful.

Test Passed

Demo
View Demo

Note: If you perform a Test Run on one of the Test Scenarios before having added the JBI module or deployed the project, the test run will fail.

Note: To resolve an issue with service endpoints when performing a test run, refer to the Ports section of the Developer Guide to BPEL Designer: Troubleshooting for instructions.

top


Debugging the Travel Reservation Service Process

You can use the IDE to debug your sample BPEL application.

General Debugging Steps

Follow these general steps when debugging your sample application:

  1. Open the Runtime window
  2. Expand the Sun Java System Application Server node.
  3. Under the JBI node, do the following:
    1. Expand Service Engines
    2. Below the JavaEEServiceEngine node, right-click com.sun.bpelse-1.0-2 to obtain Properties.

      com.sun.bpelse-1.0-2

  4. On the Properties sheet, change DebugEnabled from False to True, and remember the port setting of 3343. Note you only have to change the entry on the Properties sheet once, when you begin debugging sessions.
  5. Select Run > Attach Debugger from the main menu. The IDE displays the Attach dialog.
  6. Do the following:
    1. Ensure you have the BPEL Debugger selected as the Debugger.
    2. Ensure that the name of the host is localhost and the port is 3343.
    3. Click OK.

      Attach Window

    Demo
    View Demo

  7. In the Projects window, under the TravelReservationService node, double-click the TravelReservationService.bpel file.
  8. In the Source Editor, set breakpoints in your source code by clicking the line number of the element you want to place a breakpoint for. We will use the HasNoReservations test, so we will place breakpoints on activities invoking all three partner services.
    1. Place a breakpoint on the ReceiveItinerary receive activity at line 46. This is the activity that initiates the process. If line numbers are not visible, choose View > Show Line Numbers from the main menu.

      Set a Breakpoint in the BPEL Source

      You can also set breakpoints on the diagram. To do so, switch to the Design view, right-click the element and choose Toggle Breakpoint from the pop-up menu.

      Set a Breakpoint on the Diagram

      A red box appears at the top of the element with a breakpoint.

      A Breakpoint on the Diagram

      The Toggle Breakpoint pop-up menu command is also available for the elements in the Navigator BPEL Logical View. If the Navigator window is not open, choose Window > Navigator from the main menu. For the elements with breakpoints, the Navigator shows a small red box like the one in the following screenshot (ReceiveItinerary):

      A Breakpoint in the Navigator

    2. Place breakpoints on the ReserveAirline (line 74), ReserveVehicle (line 115) and ReserveHotel (line 156) invoke activities.

    Demo
    View Demo

  9. Now add watches to your project:
    1. If the Watches window is not visible, choose Window > Debugging > Watches from the main menu.
    2. In the Source view, go to line 71 and copy the XPath expression:
      not($ItineraryIn.itinerary/ItineraryInfo/ReservationItems/Item/Air)
      Alternatively, select the HasAirline if element on the diagram and copy the XPath expression from the Condition row in the Properties Window. If the Properties window is not visible, choose Window > Properties from the main menu.

      Copy XPath Expression from the Properties Window

    3. Right-click inside the Watches window and choose New Watch.
    4. In the New watch dialog box, paste the XPath expression into the Watch Expression field.
    5. Add two more watches for expressions at lines 112 and 153. Your Watches window should now have three items:

      Watches window

  10. In the Projects window, right-click HasNoReservations under the Test node under TraveReservationServiceApplication and choose Run.
  11. When the process reaches the first breakpoint, observe the Watches window: it should contain the <Cannot evaluate the expression> string in the Value column for all three expressions. This is because the process has stopped at the start of the very first receive activity and the ItineraryIn message has not arrived yet.
  12. Click Continue on the Debugging toolbar (Ctrl+F5). The process stops at the second breakpoint. By this time the ItineraryIn message has arrived and the conditions in the watches have been evaluated. The value of all the three expressions should be set to true.
    Note: Expressions return true if the message does not contain a corresponding reservation item. If you run the HasAirline test, the value of the not($ItineraryIn.itinerary/ItineraryInfo/ReservationItems/Item/Air) expression, which checks whether the incoming message does not contain the Airline reservation item, will be set to false.
  13. Click Continue. Observe the state of the BPEL process in the BPEL Process Instances window. Also, watch variables change their values as the process progresses in the BPEL Variables window.

Demo
View Demo


Debug Actions at a Breakpoint

Once a process instance is suspended you can perform any of the following conventional Debug toolbar actions (if the Debug toolbar is not visible, choose View > Toolbars > Debug):

  • Finish Debugger Session (Shift F5). End the current Debug session.
  • Continue (Ctrl F5). Cause the current process instance to run until it encounters the next breakpoint or until the process instance completes.
  • Step Into (F7). Steps to the next BPEL activity. This step is only supported at the granularity of Activity in BPEL language terms. It does not step at a finer granularity. As you step, the current line indicator will advance and the BPEL Variables and Watches window contents can change accordingly.


top


↑返回目录
前一篇: Tuning JVM switches for performance
后一篇: Using CVS in NetBeans IDE 5.0