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

当前页面: 开发资料首页Netbeans 专题A Simple Synchronous BPEL Process

A Simple Synchronous BPEL Process

摘要: This tutorial provides an overview of the sample project, SynchronousSample, and illustrates deploying, executing and testing a synchronous BPEL process using the NetBeans Enterprise Pack 5.5 bundle with all the necessary runtimes.

Software Needed for the Tutorial

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

Contents

top


Configuring the Tutorial Environment

Before you can deploy your application, the Sun Java System Application Server and JBI runtime must be configured correctly and running.

To configure the tutorial environment:

  1. Click the Runtime tab to open the Runtime window.
  2. In the Runtime window, expand the Servers node.
  3. If the Servers node already contains a Sun Java System Application Server 9 node, then go to step 5.
  4. If the Servers node does not contain a Sun Java System Application Server 9 node, then do the following to add an application server:
    1. Right-click the Servers node and choose Add Server from the pop-up menu.
      The Add Server Instance dialog box opens.
    2. In the Choose Server page, from the Server drop-down list, select Sun Java System Application Server.
    3. (Optional) In the Name field, accept the default value or type the name you want to use to identify the server in the IDE.
    4. Click Next.
      The Platform Location Folder page opens.
    5. In the Platform Location field, use the Browse button to navigate to and select the Application Server installation location.
      If you accepted the default values during the installation, the location is C:\Sun\Appserver.
    6. Select the Register Local Default Domain radio button.
    7. Click Next.
    8. Supply the user name and password for the domain's administrator.
      If you accepted the default values during the installation, the user name is admin and the password is adminadmin.
    9. Click Finish.
  5. In the Runtime window, right-click the Sun Java System Application Server 9 node and choose Start.
    If the Start option is not available, the server is already running and you can skip the next step.
  6. Wait until the following message appears in the Output window:
    Application server startup complete.
    When the server is running, the IDE displays a green arrow badge on the Sun Java System Application Server 9 node.

Application Server Started

top

Opening the SynchronousSample Project

  1. From the IDE's main menu, choose File >New Project.
    The New Project wizard opens.
  2. In the Categories list, select Samples>Service Oriented Architecture.
  3. In the Projects list, select Synchronous BPEL Process.

    Sample BPEL Module project selected

  4. Click Next.
  5. In the Project Name field, type SynchronousSample.

    Typing project name

  6. (Optional) In the Project Location field, use the Browse button to navigate to and select a different folder where the IDE will store the project files.
  7. Click Finish.
    The Projects window now contains two project nodes: one for a BPEL project called SynchronousSample, and one for a Composite application project called SynchronousSampleApplication.
  8. There is a broken reference in the SynchronousSampleApplication node. This is normal behavior. The Composite Application has a dependency on the JBI Module.
    You can resolve the broken reference later in the Deploying the Project to the Application Server section.

top

Exploring the BPEL Project in the Projects Window

  1. In the Projects window, expand the SynchronousSample node, then expand the Process Files node.
    The Process Files node contains these items:
    • SynchronousSample.bpel, the BPEL process
    • SynchronousSample.wsdl, the process web service interface.
    • SynchronousSample.xsd, the schema file.

    SynchronousSample Project view

  2. Double-click the SynchronousSample.bpel node.
    Notice the following:
    • The Source Editor contains a tab for SynchronousSample.bpel.
    • The SynchronousSample diagram is shown in the Design view.
      The Design view is the business processes visual designer. In this view, you can visually model a business process. The BPEL Design tool automatically generates BPEL code that corresponds to the visual design.
    • The Palette of BPEL elements opens to the right of the Source Editor.
    • The Navigator window shows the BPEL logical view of the BPEL process.

    SynchronousSample BPEL Design view
    Click to enlarge

top

Exploring the WSDL Editor in the Source Editor

The WSDL Editor enables you create and edit Web Services Description Language (WSDL) files. The WSDL editor includes a Design view and a Source view.

To see the Design View:

  1. In the Projects window, double-click the SynchronousSample.wsdl file.
    The Source Editor now contains a tab for SynchronousSample.wsdl file.
    This WSDL file is open in the Design view.
  2. In the Design view, the WSDL file appears as a tree component where you can configure the file's elements and attribute.

    SynchronousSample WSDL
    Click to enlarge

To see the Source View:

Click the Source button.
The underlying XML source code appears in the Source view.

SynchronousSample WSDL Source view
Click to enlarge

top


Adding If Activity to the Design View

  1. In the Projects window, expand the SynchronousSample node, the Process Files node and double-click the SynchronousSample.bpel node.
    The IDE displays the SynchronousSample.bpel diagram in the Design view.
  2. In the Source Editor, click the Design view.
  3. In the Structured Activities section of the Palette, select the If icon and drag your selection to the design area between the Start and Assign activities.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places an If activity called If1 in the Design view.

    If activity added

  4. In the Design view, click the If1 activity.
    The BPEL Mapper appears at the bottom of the IDE.
    If the BPEL Mapper is not visible, choose Window > BPEL Mapper.
    You use the BPEL Mapper to define the Boolean condition.
    Notice the sections at the top of the BPEL Mapper make up the Method Palette.

    BPEL Mapper

  5. From the Method Palette, click the Operator and select ==EQUAL method Equal.
    The == Equal method appears in the middle portion of the BPEL Mapper which is the Editor.
  6. From the Method Palette, click the String method and select String Literal String Literal from the String drop-down list.
    The String Literal box appears in the Editor.
  7. Type Hello World in the string literal method and press the Enter key.
  8. Move the string literal box and the == Equal box to the middle of the editor.

    Equal and String Literal inserted

  9. In the left side of the BPEL Mapper, under Variables, expand inputVar > inputType.
    paramA appears under InputType.
  10. Drag the paramA onto the any1 part of the == Equal method.
  11. Select the small square on the right side of the string literal box. When the hand cursor is visible, drag a connecting line to the any2 part of the == Equal method.
  12. From the == Equal method, drag the return boolean onto the Result.

    Mapping

top


Adding Assign Activity to the Design View

  1. In the Design view, drag the existing Assign1 activity to the If1 activity. Place this assign activity between the two large X icons in the If1 activity area.

    Assign activity added

  2. Open the Basic Activities section of the Palette and drag an Assign activity to the design area, place this second assign activity to the right of the existing assign.

    Second Assign activity added

  3. Select new Assign2 activity.
  4. From the Method Palette of the Mapper, click String method and select the concat Concat from the String drop-down list.
    The concat method appears in the middle portion of the Editor.
  5. Double-click the first field in the concat box and type Hello followed by space in the first string. Press the Enter key.
  6. From the left side of the Mapper, expand inputVar > inputType.
  7. Drag paramA onto the string2 part of the concat method, the second field.
  8. From the right of the Mapper, expand outputVar > resultType.
  9. Drag the return string from the concat method onto the paramA under outputVar > resultType.
    This concatenates the string Hello to the input and copies the statement into the output.

    String Hello concatenated

top


Deploying the project to the Application Server

Before you deploy the BPEL project, you must add the JBI module to the deployment project. Deploying the project makes the service assembly available to the application server, thus allowing its service units to be run.

To add the JBI module:

  1. In the Projects window, right-click the SynchronousSampleApplication project node and choose Add JBI Module from the pop-up menu.
    The Select Project dialog box opens.
  2. Select the SynchronousSample project and click Add Project JAR Files.

    Adding JBI Module


    The Select Project dialog box closes.
  3. In the Projects window, expand the SynchronousSampleApplication project node and then expand the JBI Modules node.
    Notice that a SynchronousSample.jar node has been added.

To deploy the Composite Application:

  1. Right-click the SynchronousSampleApplication project node and choose Deploy Project.
    Notice a message similar to the following message appears in the Output window:
    BUILD SUCCESSFUL (total time: 7 seconds).

    Output window

  1. If the Output window is not visible, choose Window > Output.

top


Creating a Test Drive

You can enhance the Composite Application project by adding test cases, binding to the operation, supplying input, and then using the Tester.

To Add a Test Case:

  1. In the Projects window, expand the SynchronousSampleApplication project node, right-click the Test node, and choose New Test Case from the pop-up menu.
    The New Test Case wizard opens.
  2. For Name, enter: MyTestcase and click Next.
  3. Expand SynchronousSample - Process Files, select SynchronousSample.wsdl and click Next
  4. Select operation1 and click Finish.
    Notice in the project tree, under Test, new folder MyTestcase is created, containing two files: Input and Output.

    MyTestcase

  5. Double-click the Input and modify its content as follows:
    1. Locate the following line in the Body contents:
      <syn:paramA>?string?<syn:paramA> .
    2. Replace ?string? with Sherry.
      The line should look like this:
      <syn:paramA>Sherry<syn:paramA> .
    3. To save your changes, from the IDE's main menu, choose File > Save.
  6. Double-click Output.xml to examine its contents.
    Notice that before the test is run this file is empty.
    Each time the test is run, the current output is compared to the contents of Output. The Input is copied to Output when Output is empty .

top


Testing the SynchronousSampleApplication

  1. In the Projects window, expand the SynchronousSampleApplication, Test, and TestCase0.
    The TestCase0 node contains two XML files: Input for input and Output for output.
    Each time the test is run, the current output is compared to the content of Output.
  2. Right-click the TestCase0 project node, and choose Run from the context menu.
    Notice this message in the Output window:

    Test passed

  3. Right-click the MyTestcase node, and choose Run from the context menu.
    This is a special case where the Output file is empty and the output is written to Output.
    The Overwrite Empty Output? dialog box displays.

    Overwrite Emplty Output?

  4. Click Yes.
  5. Notice the failed message:

    MyTestcase failed

  6. Repeat step 3.
    After the first run, the Output.xml file is no longer empty; its contents are preserved and are not overwritten by the new result.

    MyTestcase passed

Send Us Your Feedback

top


↑返回目录
前一篇: A NetBeans Platform Sample and Tutorial
后一篇: Adding Functionality to Buttons: A Beginners Guide