The Business Processes in Web Services for Java (BPWS4J) software package offers an implementation of a run-time engine that supports the Business Process Execution Language for Web Services (BPEL4WS) specification, which defines workflow and business processes for web services. This package, was released on alphaWorks in August to provide a run-time engine and a workflow editing tool for creating flows. This article focuses on an implementation exercise of a simple echo process flow, where one process receives the message and the other party reflects an identical copy of the message back to the sender.
In this article, I will assume you are familiar with the Eclipse project and using the basic Eclipse environment. The BPWS4J functions for Eclipse are explained within this article.
There are two obvious ways of moving from the rough conceptual process to a valid BPEL4WS expression of it:
- The bottom-up approach: Here you start from the primitive activities and work your way to the macro-level process, adding structure, links, and other data as you go on. The echo process will consist of two primitive tasks -- receiving a message via the
receiveactivity and replying to the sender via areplyactivity. You need to add some structure, since you necessarily require the reply to follow the response -- they cannot be executed out of turn, that wouldn't make sense for the process. This means you need sequencing, which you can enforce using thesequenceactivity. In the bottom-up approach, you define the process by creating primitive activities first and then add in the sequence later. The BPWS editor provides some support for this, allowing you to wrap a primitive activity with a structured one. So, for example, you could create thereceiveactivity and then wrap it in asequence. - The top-down approach:The other way of looking at things is starting from the outside and working your way down to primitive tasks. For the echo process, you need some steps to be taken in a certain sequence, so you add a
sequenceas the top-level activity activity and then populate it with areceiveandreplylater. The BPWS4J editor allows you to work this way as well.
An important point here is that a complete, deployable unit for the BPWS4J runtime consists of:
- The BPEL4WS file describing the process
- A WSDL file describing the messages, operations, port types and other information (service link types, correlation properties, etc.) that are referenced by the process definition (known as the process WSDL)
- the WSDL definitions for each partner involved in the process, unless the process does not make use of any WSDL operations provided by the partner
Of these, the BPWS4J editor allows you to create the BPEL4WS file describing the process. To edit WSDL files required for deploying a BPEL4WS process, you can use other tools. However, these will not support non-standard WSDL extensions that have been proposed within the BPEL4WS specification, such as service links, correlation properties, etc. Those definitions will have to be added in by hand; the samples in BPWS4J should serve as a sufficient guide for this.
I will explain what the BPWS4J editor looks like and how it functions while developing the echo process example.
To use the BPWS4J editor, you will need both the editor package from alphaWorks and the Eclipse package from the Eclipse.org web site. If you do not have Eclipse 2.0, you should download it from the Eclipse site (see Resources) and install the software.
Once you have downloaded the BPWS4J editor package -- a separate package from the BPWS4J run-time engine -- from alphaWorks (see Resources), unzip the contents into the Eclipse installation directory. Once unzipped, you should verify that you have a directory called eclipse/plugins/com.ibm.cs.bpws.tools.bpwsbuilder. You should then start up the Eclipse environment.
For this project, you begin by creating a new project in the Eclipse workspace. From the File menu, click New and select BPWS as the file type. If you do not see it in the list of available file types, you may have to click on Other file types to find it. Once you do so, you should see the screenshot in Figure 1a to determine the filename and location for the project; it also supplies default values for the process name and namespace. This moves to the next screen in Figure 1b that lets you set top-level attributes for the process such as Abstract process, Suppress join faults, Enable instance compensation, and Serializable container access; these attributes will be explained later. Make sure that you have the Open this file for editing when done option checked before you click Finish. This should create the file in the location you defined, and open it in the BPWS4J editor.
Figure 1a. Creating a new BPWS project

Figure 1b. Creating a new BPWS project II

Next you need to make sure that the BPWS perspective for Eclipse is open; this will create the views that, along with the editor area, help you define the process. From the Window menu select, Open Perspective, and choose the BPWS perspective; as before, you might have to click on Other to see BPWS as one of the options. This should open the perspective in Eclipse. The BPWS perspective consists of the Editor, the Navigator view, the Outline view, the Properties view, and the Tasks view. Next I will examine each of these in greater detail.
The Process editor and the Source editor
The BPWS4J editor is a multipage tool, with one page called the Source editor, that allows editing of the raw XML of the business process being defined; and a second page called the Process editor for a tree view of the processes involved. In the freshly created file, the default process editor tree view is displayed. Click on the Source tab in the lower left corner of the editing area to switch to the XML code view in the Source editor. Once in the Source editor, you can likewise click on the Process tab to return to the tree view.
The Process editor (see Figure 2) is a tree view of the process being displayed with nodes for all activities and BPEL4WS elements that are capable of
containing activities. For example, the process element contains the top-level activity, while the
catchFault element contains another activity to catch SOAP Fault messages.
For the newly created process, the tree will have just one node, the process element. Note that the tree view
does not display information about attributes of the process, or containers and partners defined in the process. Attempting to do so would
clutter the tree view. Instead, these are defined in the Outline and Property views of the for the process. When you select a
process node in the tree, you will see its properties appear in the Property view on the right hand side. The Outline view for this
example currently shows only the process; later, when you define containers and partners, they will appear in the Outline view after
the process node.
Figure 2. The Process view

The Source editor (see Figure 3) is a simple text editing tool that lets you edit raw XML. Editing XML by hand is error-prone and hard to do unless you know BPEL4WS syntax well, so I advise you to stay with the Process editor mostly, switching to the Source editor when you need to fill in detailed information that is cumbersome to do in the property boxes of the Process editor.
Figure 3. The Source view

The Source and Process editor are bidirectionally synchronized while you edit the information. To test this, try changing the name of the process in the
Source editor then click on the Process editor and check it. You will see the name as changed in the tree, and when you click on the process node
the updated name is reflected in the Property view as well. Now use the Property view to modify the Name
attribute of the process. When you go back to the Source editor, you will see that this same attribute has been modified in the raw XML.
Whenever your edit in the Source editor, you need to be extra careful that you do not introduce any syntax errors. This will prevent a
working BPWS file, and also prevent you from switching to the Process editor. To demonstrate, remove the > character at the end
of the <process> element in the raw XML. This is obviously invalid XML. When you click on the Process tab
to switch editors, you will get a dialog asking to correct the error, giving some details about the reason for the error. Once you put the character
back, you can switch editors.
Now you can begin building your Echo process. The root node of the process definition is the process element, as
required by the grammar of BPEL4WS. To this, add a sequence activity that will be the outermost
structural element required in the Echo process. You can add this either through the toolbar, or from the BPWS menu. The toolbar
and menu basically consist of two groups of actions:
- Addition actions: These actions add a node to an existing one in the process tree; for example, you can add a
scopeactivity to a process, or awhileactivity to a flow. There are some activity and element nodes that can only contain activities. So, you can't add acontainerelement to theprocesselement from the toolbar or menu; this can be done later in the Outline view of theprocesselement. - Wrap actions: These actions allow you to wrap an existing node inside a new node; for example you can wrap a
sequencewithin ascope, or areplywithin aflow.
Now you can go ahead and add a sequence element to the process. Next, you should add a receive
to the sequence and then a reply. If you make a mistake at any point, you can delete the
activities and start over. The delete action is also accessible via the toolbar or the menu and has the effect of deleting the subtree rooted
at the selected node.
Not all actions make sense for a particular situation; for example, the process element can contain exactly one activity.
So, once you have added your sequence, the add actions from the menu are disabled for that process node.
However, if you select the sequence element, those actions are enabled again, since a sequence can contain an unlimited
number of activities within it. The BPWS4J editor menus are thus context-sensitive and restrict the available actions so that users have a lesser
chance of making errors while creating the process.
Adding containers and partners in the Outline view
The Outline view (see Figure 4) in the BPWS4J editor is used to show the structure of the selected node in the process tree. This is in contrast to standard Outline views in Eclipse plugins, wherein the Outline applies for the entire input being displayed by the editor. Moving the details to the Outline view results in less clutter in the main Process tree view, so the designer can concentrate on the big picture (activities and their structural relationship to each other) without worrying about details.
Figure 4. The Outline view

For the echo process, you have one partner: the client from where the messages to be echoed originates. This message
has to be deposited in a container on arrival, so our process also needs to define a container. Since this message remains unaltered,
and there are no other messages involved in the process, one container is sufficient. Containers and partners are both defined within
the process element via the outline view. Select the process node in the tree, and on your Outline view
you should now be able to add a container and partner using the Outline view's toolbar. When you do this, you will see the
process element's outline get updated with each action.
Defining attributes in the Property view
You have seen how to create activities and other structural elements using the main menus and toolbar, and how to define additional elements using the Outline view. What remains is to fill in the details for each element in the attributes. You can do this using the Property view (see Figure 5).
Figure 5. The Property view

When you select a node in the Process tree or on the Outline view, the Property view is updated to reflect the properties of that particular element. This view lists the attribute names and values, and allows those values to be edited. In some cases, you will be presented with a drop down list of possible values; this is done wherever possible to reduce errors introduced by typographical mistakes. When this is not possible, you will be allow to type in text directly.
Now select the newly defined container; here you have the following two attributes: the container name and the message type. Fill these in as you would like. Note that the message type is expected to be a qualified name, and the BPWS4J editor's status bar at the bottom of the window tells you what the expected format of the qualified name is; it won't accept inputs that do not follow the required format. The message type must correspond to that defined in the process WSDL. Finally fill in the properties for the partner element in the process node's Outline view, again making sure that the information here is consistent with the process WSDL.
Checking process validity in the Task view
One of the most useful features of the BPWS4J editor is that it can check the validity of the process while it is being created. This is
done by displaying a list of errors in the Task view (see Figure 6). So far in the Echo process example, you have
created the required activities, its container, and identified the partner involved. However, you have not filled in the attributes for your
receive and reply activities. If you switch to the Source editor, you will see
that the Task view gets updated with a list of errors for our process. All of these errors relate to incomplete specification of the
receive and reply activities. If you click on a particular error in the Task view,
the offending activity definition will be highlighted in the Source editor. The Task view gets updated each time you switch editors or
if you save the process definition.
Figure 6. The Task view

While the Task view can catch many common errors, the BPWS4J editor operates in isolation and does not know the location of your process WSDL file. So references to WSDL information such as messages, operations, port types, correlation properties, or service link types cannot be validated.
You can complete the process definition by going back to your process editor and handling each outstanding task one at a time.
When you select the task, the offending node will be highlighted. You can click on the node to look at its properties, and update the
property data to get rid of the error. Once you finish the entering the properties for your receive and
reply activities your process definition is complete.
You should now have a valid process WSDL file that you can deploy and run. This will be discussed further in a future article.
- Participate in the discussion forum.
- Please note that this articles refers to version 1.0 of the BPEL4WS specification. The latest version, BPEL4WS1.1, is now available, and an article describing the key differences between the two specifications will be available shortly.
- See the official Eclipse site for more information on Eclipse.
- Check out the previous columns in the Business Process with BPEL column series.
- Download the Business Processes for web services Java runtime (BPWS4J) from alphaWorks.
- Read the full details of the Business Process Execution Language for Web Services, Version 1.0 specification.
Nirmal K. Mukhi is a Software Engineer with the Component Systems Group at the IBM T J Watson Research Laboratory, where he has been working on Web services research since November 2000. Prior to that, Nirmal was a researcher and student at Indiana University, where he received his Master's degree in May 1999. Amongst other things, Nirmal has worked on the following Web services software projects: WSDL4J, the Web Services Invocation Framework (WSIF), the Web Services Gateway (WSGW) and BPWS4J. You can contact him at nmukhi@us.ibm.com.




