The (other) Netbeans BPEL tutorial
Netbeans + the Enterprise package is probably the most appealing solution to get started with BPEL development. After all, there are not that many free
application server + BPEL engine + designer combos

However, you may find yourself quickly in a situation where you get bitten by a ton of strange errors either when developing a BPEL process or when trying to execute it. In this tutorial, I will show you how to create a simple process and mention the important points where I have already cut my teeth.
The sample BPEL process that we are going to develop is extremely simple and won't even call an external web service. Given a name and an email, it will generate a single string representation of the form
name . As you probably already know, Netbeans will require two projects to prepare and deploy a BPEL process:
- a BPEL module
- a Composite application that will reference one or more BPEL modules.
To get started, let's create a BPEL project called
ContactBPEL. To build a BPEL process, we now need to create the following files:
- an XML Schema that defines the messages that will be used as the input and outputs of the BPEL process once exposed as a Web Service
- a WSDL document that will define the static interface of our service by reusing the previous XML Schema for the data types and by defining the operations exposed by the service (usually just one for a BPEL process
- the actual BPEL process.
The general rule of thumb is that any error message from Netbeans
should not be ignored as you are sure to hit the troubles. So let's define our schema as exposed in the following screenshot.

There is one first gotcha here as we define the schema. For document-style SOAP messages, JAX-WS will not work if you reference schema elements via a
type: you will have to reference an
element. The WSDL specification work for both, but JAX-WS has a problem there. Hence,
for any complex type you need to define an element of this type. In this example we have defined a
contact element of
ContactType complex type. If you don't do that you will not be able to generate a stub from the WSDL and you will hit problems while defining the WSDL.
It's now time to move on to the WSDL document creation. The first wizard page is easy to fill, don't forget to import your XML Schema:

You can now define the abstract part of the WSDL:

You will have to reference the
elements (and not the complex type!) that you have defined to serve as the input and output of the BPEL process. However, accepting the default values would be way too easy

Even better: let's say that you leave
part1 as the message part name of the input and the
BPEL engine will crash with obscure
null pointer exceptions...
You need to specify 'body' as the message part names.
Once this is done you can move one and define a
Document/literal SOAP binding:

We can now move on and create the BPEL process file. Be happy, as you are now over with the strange and unexpected behaviors

In fact,
the Netbeans BPEL editor is a awesome. Start by dragging the WSDL to the editor, and accept the default
partner link creation (unless it doesn't specify that it is going to be
your role). The next step is to remove the empty operation, and create the skeleton of the process. Basically, the canvas is that you receive the input message, perform an assignment for building the reply and return it:

By editing the
receive and
reply activities, create the required variables named
input and
output. Making the assignment is a breeze and shows how good the BPEL editor is. Click on the
Assign activity, and the
Mapper editor will show up. From the
Strings drop-down menu, select the
Concat function, and make the connections as picture on the following screenshot:

Programming using your mouse has never been that easy

All you have to do now is to create a
Composite Application and
add a JBI module (your BPEL project) to it. Then you can start the Glassfish Application Server and deploy the composite application.
Testing the BPEL process is rather easy now, you can create a standard
Java Application and use the WSDL that you have defined to create a
Web Service Client reference, then call the service and see that it just works


It works!