Creating a Simple SOA Application With NetBeans

Contributed and maintained by Sherry Barkodar, Bob May
October 2007
[Revision number: V1-3]
This publication is applicable to NetBeans IDE/ 6.0 release

In this tutorial, you will create a simple SOA project. You will then add a WSDL document to your project and use the Partner view of the WSDL editor to add the messages, partner link type, port type, and operation. You will then create a composite application project and use the Composite Application (Service Assembly) editor to modify the project configuration. This tutorial also illustrates a basic scenario of how a File Binding Component can be used in a composite application.

Expected duration: 45 minutes

Contents

Tutorial Requirements

Before you proceed, make sure you review the requirements in this section.

Prerequisites

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

Software Needed for This Tutorial

Before you begin, you need to install the following software on your computer: NetBeans IDE 6.0 with SOA and the GlassFish application server.

top

Configuring and Starting the GlassFish Application Server

When you install full NetBeans 6.0 download, it includes the GlassFish Application Server. NetBeans will automatically start The Application Server when needed.

To start the GlassFish Application Server:

  1. If the Services window is not visible, choose Window > Services.
  2. In the Services window, expand the Servers node.
    The Servers node should contain a GlassFish Application Server subnode. If a GlassFish Application Server node does not appear, go to To configure the GlassFish Application Server .

 

  1. Right-click the GlassFish Application Server node and select Start.

    The Output window displays logging information about the application startup. If the Output window is not visible, choose Window > Output > Output

    When the message Application server startup complete. appears in the Output window, the application server is running.
    Note: If a green arrow badge appears on the GlassFish Application Server node, the server is running.

Note : Deploying an application to the GlassFish Application Server automatically starts the GlassFish Application Server. You do not have to manually start the application server.

Note: The following procedures shows how to configure the NetBeans 6.0 IDE to use an alternate version of the GlassFish V2 Application Server.

To configure the GlassFish V2 Application Server:

  1. You might want to use a different version of the application server than the one provided with NetBeans 6.0. For example, you might want to download and install a more current version of the GlassFish V2 application server from the GlassFish Community site.

    The following procedure shows how to configure the NetBeans 6.0 IDE to use an alternate version of the GlassFish V2 Application Server. It assumes that you have downloaded and installed the alternate version of the application server.

    1. In the Services window, 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 GlassFish V2.
    3. Click Next.

      The Platform Folder Location page opens.
    4. In the Platform Location field, use the Browse button to navigate to and select the installation location of the application server.

      If you installed the GlassFish application server in the default location, then use Table 1 as a guide for locating the installation. Otherwise, navigate to the location where you installed GlassFish V2 Application Server.

      Table 1: Default Application Server Installation Directory

      Platform Installing As... SOA Installation Tools Bundle Installation
      Solaris OS
      Linux
      root /opt/SUNWappserver /opt/SDK
      Solaris OS
      Linux
      user ~/SUNWappserver ~/SDK
      Mac OS X N/A ~/SUNWappserver ~/SDK
      Windows N/A C:\Sun\AppServer C:\Sun\SDK
    5. Select the Register Local Default Domain radio button and click Next.
    6. Enter 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.
    7. Click Finish.

top

Creating the BPEL Module Project

In this section, you create a BPEL Module project called HelloSample.

To create the project:

  1. From the main menu, choose File > New Project.
    The New Project wizard opens.
  2. In the Categories list, select the SOA node.
  3. In the Projects list, select the BPEL Module node.
  4. Click Next.
  5. In the Project Name field, type HelloSample.
  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 a project node for a BPEL Module project called HelloSample.

top

Creating the WSDL Document

In this section, you add a WSDL document, HelloSample.wsdl to your BPEL Module project and then you use the Partner view of the WSDL editor to configure the components of the WSDL document.

To create the WSDL document:

  1. In the Projects window, expand the HelloSample project node, right-click the Process Files node and choose New > WSDL Document.
    The New WSDL Document wizard opens.
  2. In the File Name field, type HelloSample.
  3. Click Finish.

    New WSDL document open in WSDL editor and visible Properties window, click to enlarge

To add messages:

  1. In the WSDL view, click the Partner button to open the Partner view of the WSDL editor.
    The editor switches to the Partner view and the Palette is opened.
    If the Palette window is not visible, choose Window > Palette from the main menu.
  2. In the WSDL Components section of the Palette, select the Message icon.
  3. Drag your selection to the Partner view design area, into the Messages area (the lower part of the design area).
    The IDE adds a message called message1.

    Message added to WSDL document

    Note: If you do not see the Part Name and Part Element or Type columns, click the down arrow in the message1 box to expand the box.
  4. In the Part Name column for message1, double-click the default value, part1 to make the field editable.
  5. Type inputType and press Enter.
  6. In the Part Element or Type column for message1, click the ellipsis button, and in the dialog box that opens, expand Built-In Schema Types, select string and click OK.
  7. Repeat steps 2-6 to create another message, message2 and use resultType as the Part Name.
    When you are done, your design area should look similar to the one shown below.

    Two message added to WSDL document, click to enlarge

To add a partner link type:

  1. In the WSDL Components section of the Palette, select the Partner Link Type icon.
  2. Drag your selection to the design area, into the Partner Link Types area (the upper part of the design area).
    The IDE adds a partner link type called partnerlinktype1. You can now create new roles and port types. Roles and port types are drawn as dotted vertical lines with the external names shown at the top.

    Partner link type added to WSDL document, click to enlarge

  3. In the partnerlinktype1 box, double-click the box under role1.
    This makes the port type editable and a default value portType1, appears in the field.
  4. Press Enter.
    The new portType1 is assigned.
  5. In the WSDL Components section of the Palette, select the Request-Response icon.
  6. Drag your selection to the design area, below portType1.
    The IDE adds an operation, operation1.

    Request-response added to WSDL document, click to enlarge

  7. Under operation1, select the solid message arrow labeled <No Message Selected>.
  8. In the Properties window, from the Message drop-down list, select tns:message1.
    The label changes to message1.
  9. Under operation1, select the dotted message arrow labeled <No Message Selected>.
  10. In the Properties window, from the Message drop-down list, select tns:message2.
    The label changes to message2.
    When you have completed these steps, your design area should look similar to the one shown below.

    Partner link type added to WSDL document, click to enlarge

top

Creating the BPEL Process

In this section, you add a BPEL process file, HelloSample.bpel. You then add a partner link and three activities to the BPEL process file.

To create the BPEL process file:

  1. In the Projects window, expand the HelloSample project node, right-click the Process Files node and choose New > BPEL Process.
    The New BPEL Process wizard opens.
  2. In the File Name field, type HelloSample.
  3. Click Finish.
    The IDE window should look similar to the one shown below.

    BPEL process file added, click to enlarge

To add a partner link:

  1. In the Web Service section of the Palette, select the Partner Link icon and drag your selection to the design area.
    The Create New Partner Link dialog box opens.
  2. Accept the defaults (Name: PartnerLink1, WSDL File: /HelloSample.wsdl, Use Existing Partner Link Type radio button selected) and click OK.
    The IDE adds the partner link to the design area.

    Partner link added to BPEL process file

To add a receive activity:

  1. In the Web Service section of the Palette, select the Receive icon.
  2. Drag your selection to the HelloSample box in the design area, between the Process Start and the Process End activities.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places a receive activity called Receive1 in the Design view.
  3. Double-click the Receive1 activity.
    The Receive1 [Receive] - Property Editor opens.
  4. On the Main tab, from the Partner Link drop-down list, select PartnerLink1.
    The IDE fills in the Operation field with operation1.
  5. Create a new input variable by doing the following:
    1. Click the Create button next to the Input Variable field.
      The New Input Variable dialog box opens.
    2. Change the value in the Name field to inputVar.
    3. Click OK.
  6. Click OK to close the Receive1 [Receive] - Property Editor.
    The Design view now shows a connection between operation1 in PartnerLink1 and the Receive1 activity.

    Receive activity added to BPEL process file

To add a reply activity:

  1. In the Web Service section of the Palette, select the Reply icon.
  2. Drag your selection to the design area between the Receive1 activity and the Process End activity.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places a reply activity called Reply1 in the Design view.
  3. Double-click the Reply1 activity.
    The Reply1 [Reply] - Property Editor opens.
  4. On the Main tab, from the Partner Link drop-down list, select PartnerLink1.
    The IDE fills in the Operation field with operation1.
  5. Create a new output variable by doing the following:
    1. Make sure the Normal Response radio button is selected.
    2. Click the Create button next to the Output Variable field.
      The New Output Variable dialog box opens.
    3. Change the value in the Name field to outputVar.
    4. Click OK.
  6. Click OK to close the Reply1 [Reply] - Property Editor.
    The Design view now shows a connection between the Reply1 activity and operation1 in PartnerLink1.

    Reply activity added to BPEL process file

To add an assign activity:

  1. In the Basic Activities section of the Palette, select the Assign icon.
  2. Drag your selection to the design area between the Receive1 activity and the Reply1 activity.
    This action places an assign activity called Assign1 in the Design view.
  3. Select the Assign1 activity.
  4. If the BPEL Mapper window is not visible, choose Window > Other > BPEL Mapper from the main menu.
  5. In the Source tree pane (the left pane) of the BPEL Mapper, under Variables, expand the inputVar node.
    An inputType node appears under the inputVar node.
  6. In the Destination tree pane (the right pane) of the BPEL Mapper, under Variables, expand the outputVar node.
    A resultType node appears under the outputVar node.
  7. In the Source tree pane, select the inputType node and drag your selection to the resultType node in the Destination tree pane.
    This assignment copies the input statement into the output.

    Result of assignment in BPEL Mapper, click to enlarge

  8. To save your changes, in the Projects window, select the HelloSample project node, and from the main menu, choose File > Save All.

top

Creating the Composite Application Project

Before you deploy the BPEL Module 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 create the Composite Application project:

  1. From the main menu, choose File > New Project.
    The New Project wizard opens.
  2. In the Categories list, select the SOA node.
  3. In the Projects list, select the Composite Application node.
  4. Click Next.
  5. In the Project Name field, type SampleCompositeApp.
  6. Click Finish.
    The Projects window now contains a project node for a Composite Application project called SampleCompositeApp.

    Projects window with new project node for Composite Application project

top

Using the Composite Application (Service Assembly) Editor

In this section, you use the Composite Application (Service Assembly) editor to modify the project configuration and build the BPEL Module project. You then add a WSDL endpoint and a connection and then you verify and change the properties of the auto-generated WSDL endpoints.

To use the Composite Application (Service Assembly) editor to modify the project configuration and build the BPEL Module project:

  1. In the Projects window, select the SampleCompositeApp project node and choose Edit Application Configuration from the pop-up menu.
    The IDE opens the .casa file in the Composite Application (Service Assembly) editor. The design area of the Design view of the editor has three parts: WSDL Ports, JBI Modules, and External Modules.

    CASA editor, design area of the Design view

  2. In the Projects window, select the HelloSample project node and drag your selection to the JBI Modules area in the Design view of the SampleCompositeApp.casa file.

    JBI Module added using Composite Application editor, click to enlarge

  3. In the editor toolbar, click the Build Project button to build the HelloSample BPEL Module project.
    When this step has completed:

To create the WSDL endpoint:

  1. In the WSDL Bindings section of the Palette, select the file icon.
  2. Drag your selection to the WSDL Ports area in the Design view of the SampleCompositeApp.casa file.
    The IDE adds a WSDL port labeled casaPort1.

    Design view after WSDL endpoint casaport1 is added

To create a connection:

  1. In the casaPort1 port in the Design view, click the consume endpoint icon, .
    The colors of the icon change when you select the endpoint: .
  2. Drag your selection to role1_myRole in the (BPEL) HelloSample box in the JBI Modules area.
    The IDE creates a new connection.

    Design view after adding connection

To verify and change the properties of the auto-generated WSDL endpoint:

  1. If the Navigator window is not visible, choose Window > Navigating > Navigator from the main menu.
  2. In the Navigator window, from the drop-down list, select Logical View.
  3. Expand WSDL Ports > casaPort1 > casaBinding1 > operation1 > input1 and select the file:message node.

    Navigator window, file:message node under input1 selected

  4. If the Properties window is not visible, choose Window > Properties from the main menu.
    The Properties window shows the properties of the file:message node you selected in the Navigator window.
  5. In the Properties window, change the properties to match the values shown below:

    Property Value
    use literal
    fileName input.txt
    pollingInterval 5000
  6. In the Navigator window, expand WSDL Ports > casaPort1 > casaBinding1 > operation1 > output1 and select the file:message node.

    Navigator window, file:message node under output1 selected

  7. In the Properties window for file:message, assign output.txt to the fileName property.
  8. In the Navigator window, expand WSDL Ports > casaPort1 > casaPort1 and select the file:address node.

    Navigator window, file:address node under casaPort1 selected

  9. In the Properties window for file:address, in the fileDirectory property, replace C:\Temp with the string c:\test.
  10. To save your changes, in the Projects window, select the SampleCompositeApp project node, and from the main menu, choose File > Save All.

top

Deploying and Testing the Composite Application

In this section, you deploy the Composite Application project and then test that deployed application. If you skipped the steps in Configuring and Starting the Sun Java System Application Server earlier in this tutorial, you must perform them before these deployment and test tasks.

To deploy the Composite Application:

To test the Composite Application:

top

Summary

In this tutorial, you created a BPEL Module project. You then added a WSDL document to your project and used the Partner view of the WSDL editor to add the messages, partner link type, port type, and operation. Next, you created a composite application project and used the Composite Application (Service Assembly) editor to modify the project configuration. You also used the File Binding Component in the composite application.

top

Next Steps

See Also

Send Us Your Feedback

top

www.000webhost.com