BPEL Designer Kick Start - NetBeans

netbeans.org

BPEL Designer Kick Start - NetBeans

BPEL

Designer

Kick Start

Exploring NetBeans’ Visual Design

Capabilities to Create a BPEL Process

and a Composite Application

Sherry Barkodar


BPEL Designer Kick Start

This tutorial illustrates

deploying, executing and

testing a synchronous BPEL

process using NetBeans

5.5 with Enterprise Pack. A

synchronous BPEL process represents

a simple synchronous flow: it takes an

input message and sends that message

back synchronously. A client starts the

synchronous process by invoking a request-response

operation. After invocation,

the client is blocked until the process

finishes and returns the result.

Configuring the

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 environment:

1. Click the Runtime

tab to open the Runtime window, and expand

the Servers node.

A 1

2. If you have a default Enterprise Pack

installation the Servers node already contains

a Sun Java System Application Server

9 node. In the Runtime window, right-click

this node and choose Start. If the Start option

is not available, the server is already

running and you can skip the next step.

3. Wait until a completion message

appears in the Output window (see

Figure 1). When the server is running,

the IDE displays a green arrow on the

Sun Java System Application Server 9 node.

Creating the sample project

From the IDE’s main menu, choose File>New Project. In the

Categories list, select Samples>Service Oriented Architecture, and

then Synchronous BPEL Process (see Figure 2).

Click Next. In the Project Name field, type “SynchronousSample”

(this is the default value). Optionally in the Project Location field,

use Browse to select a different folder for the project files.

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.

Note that there is a broken reference in the

SynchronousSampleApplication node. This is expected. The

Composite Application has a dependency on the JBI Module. We’ll

resolve the broken reference later in the article, when we deploy

the project.

A

2

A

Figure 1.

A successful

server

startup.

A

Figure 2.

Creating the

BPEL process

Second Edition N 57


BPEL & SOA

A

A 3

Figure 3.

Files in the

sample

application

A A 4

Figure 4.

Designing the

BPEL process

Exploring the BPEL Project

In the Projects window, expand the SynchronousSample node;

then expand Process Files. This node contains the following items

(see Figure 3):

• SynchronousSample.bpel, the BPEL process

• SynchronousSample.wsdl, the process web service

interface.

• SynchronousSample.xsd, the schema file.

Double-click the SynchronousSample.bpel node (see Figure 4).

Notice the following:

• The Source Editor has a tab for SynchronousSample.bpel.

• The SynchronousSample diagram is shown in the Design

view. The Design view allows you to visually model a business

process. The BPEL Design tool automatically generates BPEL

code that corresponds to the visual design.

• The Palette of BPEL elements is located to the right of the

Source Editor.

• The Navigator window shows the

BPEL logical view of the BPEL process.

Exploring the WSDL Editor

The WSDL Editor enables you to create

and edit Web Services Description

Language (WSDL) files. It includes a Design

view and a Source view. To see the Design

View, in the Projects window double-click

the SynchronousSample.wsdl file. In this

view, the WSDL file appears as a tree component

where you can configure the file’s

elements and attributes (see Figure 5).

To see the Source View, click the Source

button. The underlying XML source code

appears, as shown in Figure 6.

Adding an If activity

In the Projects window, double-click on

SynchronousSample.bpel. The IDE displays

the SynchronousSample.bpel diagram

in the Design view. In the Source Editor,

change to the Design view (if you’re not

there already). In the Structured Activities

section of the Palette, select the If activity

and drag it to the design area between

Start and Assign. The IDE provides visual

58 N NetBeans Magazine


BPEL Designer Kick Start

A

5

A

Figure 5.

WSDL Editor

Design view

A 6

A

Figure 6.

WSDL Editor

Source view

A

7

A

Figure 7.

Adding an If

activity

Second Edition N 59


BPEL & SOA

A A 8

Figure 8.

BPEL Mapper

window

cues showing where you can drop the selection. This adds an If

activity called If1 (see Figure 7).

In the Design view, click the new If1 activity. The BPEL Mapper appears

at the bottom of the IDE (see Figure 8). (If the BPEL Mapper

is not visible, choose Window>BPEL Mapper.) We’ll use the BPEL

Mapper to define the Boolean condition for the If. The sections at

the top of the BPEL Mapper make up the Method Palette.

From the Method Palette, click Operator and select Equal

( ). The Equal method appears in the middle portion of

the BPEL Mapper (the Editor). Click String and select String Literal

( ) from the drop-down list. The String Literal box appears

in the editor (you may need to drag it to the side). Type “Hello

A A 9

Figure 9.

First step of

the mapping

A A 10

Figure 10.

Completed

mapping

60 N NetBeans Magazine


BPEL Designer Kick Start

World” in the String Literal and press Enter. Then move the String

Literal box and the Equal box to the middle of the editor (see the

current mapping in Figure 9).

In the left side of the BPEL Mapper, under Variables, expand

inputVar>inputType. Drag paramA onto the any1 part of the Equal

method. Select the small square on the right side of the String

Literal box; then, when the hand cursor is visible, drag a connecting

line to the any2 part of the Equal method. Finally, from the

Equal method, drag the return boolean section on to the Result (in

the rightmost part of the BPEL Mapper).

Adding an

Assign Activity

In the Design view, drag the

existing Assign1 activity to the

If1 activity. Place the activity between

the two large X icons in the

If1 activity area, as in Figure 11.

Open the Basic Activities section

in the Palette and drag a new Assign

activity to the design area,

placing it to the right of the existing

one (Figure 12).

Select the new Assign2 activity.

From the Method Palette of the

Mapper, click on String and select

concat (

) from the

drop-down list. The concat method

appears in the editor. Doubleclick

the first field in the concat

box and type “Hello” followed by

space, in the first string. Then

press Enter or click outside the

box.

In the left side of the Mapper,

expand

inputVar>inputType.

Drag paramA onto the string2

part of the concat method, the

second field. On the right of the

A 11

A 12

A

Figure 11.

First Assign

activity

A

Figure 12.

Adding a second

Assign activity

Second Edition N 61


BPEL & SOA

A A 13

Figure 13.

Assign2

activity

mapping

Mapper, expand outputVar>resultType.

Drag the return string part from the

concat method onto the paramA under

outputVar>resultType. See Figure 13.

This concatenates the string Hello to the

input and copies the statement into the

output.

A

Figure 14.

Adding a JBI

Module to the

Synchronous

Sample

Application

A

Figure 15.

Deployment

results for the

Composite

Application

A

Figure 16.

Results for the

first test.

A 14

A 15

A 16

Deploying the project

Before you deploy the BPEL project, you

need to 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, in the

Projects window, right-click the

SynchronousSampleApplication project

node and choose Add JBI Module

from the pop-up menu. Select the

SynchronousSample project and click

Add Project JAR Files (see Figure 14).

In the Projects window, expand the

SynchronousSampleApplication project

node and then the JBI Modules node.

Notice that a SynchronousSample.jar node

has been added.

To deploy the Composite Application, rightclick

the SynchronousSampleApplication

project node and choose Deploy Project;

then confirm the use of the SJSAS application

server. You’ll see a message like

the one shown in Figure 15 in the Output

window (if the Output window is not visible,

choose Window>Output).

62 N NetBeans Magazine


BPEL Designer Kick Start

A

17

A

Figure 17.

Confirmation

for saving

to an empty

Output.xml

A 18

A

Figure 18.

Results for the

second test.

Testing the composite

application

You can enhance the Composite

Application project by adding test cases,

binding to the operation, supplying input,

and then using the Tester.

In the Projects window, expand the

SynchronousSampleApplication

project

node, right-click the Test node, and choose

New Test Case from the context menu. The

New Test Case wizard opens. For Name,

enter (say) “MyTestcase” and click Next.

Expand

SynchronousSample-Process

Files, select SynchronousSample.wsdl

and click Next.

Select operation1 and click Finish. Notice

that in the project tree, under Test, a new

folder MyTestcase is created, containing

two files: Input and Output. Double-click

Input and in the Body contents replace

string

with

Sherry.

Then save the project.

Double-click Output.xml and 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 will be copied to Output when Output is empty.

Testing the

SynchronousSampleApplication

In the Projects window, expand to SynchronousSampleApplication>

Test>TestCase0. The TestCase0 node contains two XML files:

Input.xml and Output.xml. Right-click the TestCase0 project node

and choose Run. A pass message should be shown in the Output

window (see Figure 16).

Right-click the MyTestcase node, and choose Run from the context

menu. This is a special case where the Output file is empty,

so the output is written to Output. Before that, a confirmation dialog

is displayed (Figure 17); click Yes. Notice the failed message

(Figure 18). Repeat the last test. After the first run, the Output.xml

file is no longer empty, so its contents are preserved and are not

overwritten by the new result. And the test passes.

Conclusions

In this tutorial, you’ve seen how to use the NetBeans BPEL designer

to create a synchronous process, and how productive developing,

testing and deploying composite applications is with the

new features in the NetBeans Enterprise Pack.

C

Sherry Barkodar

(sherry.barkodar@

sun.com) has

been with Sun

for 7 years, and

currently designs

and implements

Enterprise Pack

tutorials and

examples. She

holds an architect

degree from Tehran

University and a

MSCS degree from

SJSU. You can visit

her blog at blogs.

sun.com/barkodar.

Second Edition N 63

More magazines by this user
Similar magazines