
Developing a Hello World Composite Application
Download ZIP file for offline reading (includes video demo files, 4.55 MB)
In this tutorial, you create a simple BPEL Module project called SynchronousSample and a Composite Application project called SynchronousSampleApplication. This tutorial illustrates how to design a simple XML schema file, a simple WSDL file, and a BPEL file. You learn how to design a BPEL process and deploy. You also learn how to create and perform a test run of a composite application. The process is a simple BPEL process that echoes back the input message. The BPEL process returns the result to the client synchronously. A client starts the BPEL process by invoking a request-response operation. The client is blocked until the process finishes and returns the result. The project includes WSDL and XML schema files, and input files for testing.
This tutorial is intended to be the first step towards building a more complex composite application.
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 topic of the NetBeans Enterprise Pack 5.5 Release Notes.
Software Needed for the Tutorial
Before you begin, you must install the following software on your computer:
- NetBeans IDE 5.5 (download) with NetBeans Enterprise Pack 5.5 (download)
- In order to complete the deployment steps in this tutorial, you must have Sun Java System Application Server Platform Edition 9 Update 1. This Application Server is bundled with the NetBeans Enterprise Pack 5.5 download.
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:
- Click the Runtime tab to open the Runtime window.
- In the Runtime window, expand the Servers node.
- If the Servers node already contains a Sun Java System Application Server 9 node, then go to step 5.
- If the Servers node does not contain a Sun Java System Application Server 9 node, then do the following to add an application server:
- Right-click the Servers node and choose Add Server from the pop-up menu.
The Add Server Instance dialog box opens.
- In the Choose Server page, from the Server drop-down list, select Sun Java System Application Server.
- (Optional) In the Name field, accept the default value or type the name you want to use to identify the server in the IDE.
- Click Next.
The Platform Location Folder page opens.
- 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.
- Select the Register Local Default Domain radio button.
- Click Next.
- 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.
- Click Finish.
- 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.
- 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.
View Demo
top
Creating the Project
In this section, you create a BPEL Module project called SynchronousSample.
To create the SynchronousSample project:
- From the IDE's main menu, choose File > New Project.
The New Project wizard opens.
- In the Categories list, select the Service Oriented Architecture node.
- In the Projects list, select the BPEL Module node.
- Click Next.
- In the Project Name field, type SynchronousSample.
- (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.
- Click Finish.
The Projects window now contains a project node for a BPEL Module project called SynchronousSample.
View Demo
top
Creating the XML Schema
In this section, you add a new XML schema file to your BPEL Module project and then add XML schema components to the schema.
To create SynchronousSample.xsd:
- In the Projects window, expand the SynchronousSample project node, then right-click the Process Files node and choose New > File/Folder.
The New File wizard opens.
- In the New File wizard, do the following:
- In the Choose File Type page, in the Categories list, select the XML node, then in the File Types list, select the XML Schema node and click Next.
- In the File Name field, type SynchronousSample.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled SynchronousSample.xsd. The Source Editor contains a tab for the XML schema file, SynchronousSample.xsd, with the Schema view open.
- In the Schema view, click the Design button to open the Design view of the XML schema editor.
View Demo
To add a complex type to the XML schema:
- In the Palette of the Design view, expand the XML Schema Components section and select the Complex Type icon.
If the Palette window is not visible, choose Window > Palette from the main menu.
- Drag your selection to the schema design area, immediately below the Complex Types node.
The IDE adds a complex type node and the name of the complex type (newComplexType) is selected and ready for you to change.
- Type simpleProcess in the new node and press Enter.
The design area now shows your new complex type, called simpleProcess.
View Demo
To add a local element to simpleProcess:
- In the XML Components section of the Palette, select the Element icon and drag your selection onto the simpleProcess node in the schema design area.
The IDE adds an element node labeled newElement.
- If the Properties window is not visible, choose Window > Properties.
- In the schema design area, select the newElement node.
- In the Properties window, select the value field of the Name property to make it editable and type paramA.
- In the Properties window, in the Definition property, click the ellipsis button.
The Definition dialog box opens.
- In the list, expand the Built-in Types node and select the string node.
- Click OK.
View Demo
To add a global element:
- In the XML Components section of the Palette, select the Element icon and drag your selection to the design area, immediately below the Elements node.
The IDE adds a newElement component below the Elements nodes in the schema design area.
- In the schema design area of the Design view, select the newElement node.
- In the Properties window, select the value field of the Name property to make it editable and type typeA.
- In the Properties window, in the Definition property, click the ellipsis button.
The Element's definition - Definition dialog box opens.
- In the list of types, expand the Complex Types node and select the simpleProcess complex type node.
- Click OK.
In the Design view, the IDE now shows the selected simpleProcess complex type next to the typeA element node.
- To save your changes, in the Projects window, select the SynchronousSample project node, and from the IDE's main menu, choose File > Save All.
View Demo
top
Creating the WSDL Document
In this section, you add a WSDL file to your BPEL Module project and then configure the components of the WSDL Document.
To create SynchronousSample.wsdl:
- In the Projects window, expand the SynchronousSample project node, then right-click the Process Files node and choose New > WSDL Document.
The New WSDL Document wizard opens.
- In the Name and Location page, do the following:
- In the File Name field, type SynchronousSample.
- Select the Import XML Schema File(s) checkbox.
- In the XML Schema(s) field, click the Browse button.
The Select Schemas dialog box opens. This dialog box shows the XML schemas in your project.
- Select src/SynchronousSample.xsd and click OK.
- Click Next.
The Abstract Configuration page opens.
- In the Input area of the Abstract Configuration page, do the following:
- In the Message Part Name column, double-click the default value to make the field editable.
- Type inputType and press Enter.
- In the Element Or Type column, click the ellipsis button.
The Select Element Or Type dialog box opens.
- Expand the SynchronousSample node, the src/SynchronousSample.xsd node, and the Elements node.
- Under the Elements node, select the typeA node and click OK.
- In the Output area of the Abstract Configuration page, do the following:
- In the Message Part Name column, double-click the default value to make the field editable.
- Type resultType and press Enter.
- In the Element Or Type column, click the ellipsis button.
The Select Element Or Type dialog box opens.
- Expand the SynchronousSample node, the src/SynchronousSample.xsd node, and the Elements node.
- Under the Elements node, select typeA and click OK.
- Click Next.
The Concrete Configuration page opens.
Note: When you perform the next step, the error message at the bottom of the page disappears.
- Under Binding Subtype, select the Document Literal radio button.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled SynchronousSample.wsdl.
The Source Editor contains a tab for the WSDL file, SynchronousSample.wsdl, with the WSDL view open.
View Demo
top
Creating the BPEL Process
To create SynchronousSample.bpel:
- In the Projects window, right-click the Process Files node and choose New > BPEL Process.
The New BPEL Process wizard opens.
- In the File Name field, type SynchronousSample.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled SynchronousSample.bpel.
The Source Editor contains a tab for the BPEL process, SynchronousSample.bpel, with the Design view of the BPEL Designer open.
View Demo
To add a partner link:
- In the Projects window, expand the SynchronousSample project node, then expand the Process Files node and select the SynchronousSample.wsdl node.
- Drag your selection (SynchronousSample.wsdl) from the Projects window to the Design view.
The Partnerlink1 [Partner Link] - Property Editor opens.
- Accept the defaults and click OK.
View Demo
To add a Receive activity:
- In the Web Service section of the Palette, select the Receive icon and drag your selection to the design area between the Process Start activity and the Empty activity.
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.
- Double-click the Receive1 activity.
The Receive1 [Receive] - Property Editor opens.
- Change the value in the Name field to start.
- From the Partner Link drop-down list, select PartnerLink1.
The IDE fills in the Operation field.
- Create a new input variable by doing the following:
- Click the Create button next to the Input Variable field.
The New Input Variable dialog box opens.
- Change the value in the Name field to inputVar.
- Click OK.
- Click OK to close the Receive1 [Receive] - Property Editor.
The Receive activity is now labeled start in the Design view.
View Demo
To add a Reply activity:
- In the Web Service section of the Palette, select the Reply icon and drag your selection to the design area between the empty 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.
- Double-click the Reply1 activity.
The Reply1 [Reply] - Property Editor opens.
- Change the value in the Name field to end.
- From the Partner Link drop-down list, select PartnerLink1.
The IDE fills in the Operation field.
- Create a new output variable by doing the following:
- Make sure the Normal Response radio button is selected.
- Click the Create button next to the Output Variable field.
The New Output Variable dialog box opens.
- Change the value in the Name field to outputVar.
- Click OK.
- Click OK to close the Reply1 [Reply] - Property Editor.
The Reply activity is now labeled end in the Design view.
View Demo
To add an Assign activity:
- In the design area, select the empty activity, right-click and choose Delete from the pop-up menu.
- In the Basic Activities section of the Palette, select the Assign icon and drag your selection to the design area between the start activity and the end activity.
This action places an Assign activity called Assign1 in the Design view.
- Select the Assign1 activity.
- If the BPEL Mapper window is not visible, choose Window > BPEL Mapper from the main menu.
- In the left pane of the BPEL Mapper, under Variables, expand the inputVar and inputType nodes.
paramA appears under inputType.
- In the right pane of the BPEL Mapper, under Variables, expand the outputVar and resultType nodes.
paramA appears under resultType.
- Drag paramA from the left pane of the BPEL Mapper to the paramA node in the right pane of the BPEL Mapper.
This assignment copies the input statement into the output.
- To save your changes, in the Projects window, select the SynchronousSample project node, and from the IDE's main menu, choose File > Save All.
View Demo
top
Creating and Deploying the Composite Application
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 and add the JBI module:
- From the IDE's main menu, choose File > New Project.
The New Project wizard opens.
- In the Categories list, select the Service Oriented Architecture node.
- In the Projects list, select the Composite Application node.
- Click Next.
- In the Project Name field, type SynchronousSampleApplication.
- Click Finish.
The Projects window now contains a project node for a Composite Application project called SynchronousSampleApplication.
- 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.
- Select the SynchronousSample project you created earlier in this tutorial and click Add Project JAR Files.
The Select Project dialog box closes.
- 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.
View Demo
To deploy the Composite Application:
- Right-click the SynchronousSampleApplication project node and choose Deploy Project.
If a message similar to the following message appears in the Output window, then the deployment has succeeded:
BUILD SUCCESSFUL (total time: 11 seconds)
View Demo
top
Testing the SynchronousSampleApplication
You can enhance the Composite Application project by adding test cases, binding to the operation, supplying input, and then using the Tester.
To test the SynchronousSampleApplication:
- 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.
- Accept the default test case name, TestCase1, and click Next.
- In the Select the WSDL Document page, expand the SynchronousSample - Process Files node, select SynchronousSample.wsdl, and click Next.
- In the Select the Operation to Test page, select the SynchronousSampleOperation and click Finish.
In the Projects window, under Test, a new TestCase1 node has been added.
This node contains two subnodes: Input and Output.
The Source Editor contains a tab for the Input file, Input.xml.
- If the Source Editor does not contain a tab for Input.xml, double-click the Input node in the Projects window to open the file.
- In the Source Editor tab for the Input.xml file, do the following:
- Locate the following line:
<syn:paramA>?string?<syn:paramA>.
- Replace ?string? with Hello World.
The line should look like this:
<syn:paramA>Hello World<syn:paramA>.
- From the IDE's main menu, choose File > Save All.
- Double-click Output to examine its contents.
Initially, output.xml is empty. Therefore the first test run will populate output.xml with the real output. Subsequent test runs will compare the real output against the contents of output.xml.
- In the Projects window, right-click the TestCase1 node and choose Run from the pop-up menu.
Note: The first run is a special case because Output.xml is empty and the output is written to Output.
Notice the failed message in the JUnit Test Results window.
The Overwrite Empty Output? dialog box opens.
- Click Yes.
- In the Projects window, right-click the TestCase1 node and choose Run from the pop-up menu.
After the first run, Output is no longer empty. The file's contents are preserved and are not overwritten by the new result.
View Demo
top
|
|