Professional Documents
Culture Documents
Version 1.2
September 3, 2009
- 1 of 99 -
Table of Contents
Objectives ..................................................................................................................................... 4
Environment ................................................................................................................................. 5
Scenario
Business Conversation ..................................................................................................... 6
Technical Architecture ...................................................................................................... 8
Summary ........................................................................................................................................ 97
References .....................................................................................................................................99
- 3 of 99 -
Objectives
This tutorial supports knowledge transfer for technology in the Sun-sponsored OpenESB
community. The GlassFish ESB product from Sun provides support for a subset of the
capabilities developed in OpenESB. This material is designed to help you develop skills so
you can start using some of the BPEL-related technical aspects of GlassFish ESB.
This tutorial document provides complete, step-by-step exercises for self-study lab time to so
you can create this GlassFish demonstration. In the projects that follow, you will build the
demo from scratch and see insights into both the business case and technical features.
Thanks to Michael Czapski for his excellent demo. He's a real pro. I hope that I have done his
demo justice in this document. You may want to follow Michael's ongoing SOA/BI work at his
blog at http://blogs.sun.com/javacapsfieldtech/.
I appreciate your interest in GlassFish ESB, OpenESB and/or Java CAPS and am very
interested in your feedback on this tutorial.
-- Thomas.Barrett@sun.com
- 4 of 99 -
Environment
You'll need a modern computer with at least 2GB of RAM (the more the merrier) and about
1GB of free disk space. Although the JDK and NetBeans work on a broad range of
operating systems, we'll assume that you are using Windows XP. Since the products are
written in 100% pure Java, you will likely be successful with another operating system, but the
instructions were tested on a Windows XP (SP3) laptop.
You'll need to have JDK 6 and the latest GlassFish ESB installed. Download the latest JDK
from http://java.sun.com/javase/downloads/index.jsp and install it. Then, download and
install the latest builds of Sun's ESB technology from: https://open-
esb.dev.java.net/Downloads.html. This version of the tutorial was last successfully tested with
JDK 6 Update 10 and the GlassFish ESB 2.1.
Tutorial Format
In the pages that follow, you'll see a 3-column format. In the first column, we'll include headings
to act as mileposts to remind you of the purpose of the steps in the section. Hopefully, these
headings will also be helpful later as you use this document as a reference. Each heading is
listed in the table of contents to help you find a section quickly.
In the second column, we've included detailed, step-by-step guidance on the keystrokes and
mouse clicks required to accomplish the tasks. Along the way, you will find illustrations so you
can compare what you see on your screen to what we intend.
In the third column, you'll find narrative (in green) that provides background to the steps listed
in the second column. I call this the “buddy column” since these it contains things I might point
out if we were sitting together at the keyboard. I have included some conceptual topics,
informal advice and some deeper technical tips in the column 3. Having these comments in a
separate column hopefully keeps the second column more concise while providing some
deeper insight into the projects.
In step-by-step exercises, it's easy to get into “mind-numbing” keyboard and mouse clicking
and not understanding what's really going on. Hopefully, the “buddy column” provides some of
the “whys” for all the “whats” and “hows” covered in column 2.
- 5 of 99 -
Scenario
The focus of this tutorial is an abbreviated supply chain. We'll feature OpenESB capabilities that
are packaged in Sun's GlassFish ESB offering. The same OpenESB technology is also a part
of Java CAPS and the Sun ESB Suite. Before we dive into the technical details, let's overview
the overarching business policy and scenario for the projects we'll tackle.
The supplier then submits the DN to the shopping We will not implement the
portal which forwards it to the purchasing system so shipper system in this
tutorial. We'll just assume
it can match the DN with the initiating PO. As the that as soon as the supplier
DNs and POs are matched, a note is sent to the receives a PO that they will
finance department so that the customer can be return a DN to the purchaser.
billed, the supplier paid and the shipper reimbursed.
- 6 of 99 -
As shown below, we conceive the business By “Internet Shop”, we mean
environment as four distinct entities. The Internet and Internet-based storefront
like Amazon.com.
Shop encompasses the Web Portal, Purchasing
Back Office and the Finance department. The
Supplier is a separate function not under the control
of the Internet Shop. The Shipper is another
independent third-party. On the top, we have the
most important entity of all – the customer.
- 7 of 99 -
Technical The technical scenario is a fairly rich one. The two
Architecture key processes, Purchaser and Supplier are
implemented as BPEL processes. They orchestrate
interactions that utilize SOAP, file and JMS. A
typical flow through the system is illustrated below
and includes these processing steps:
- 8 of 99 -
Project 0: Preparing the Environment
Before we can get started building the Purchaser and Supplier processes, we need to make
sure that we have all we need in our GlassFish ESB environment. Let's take a moment to check
that we have all the plug-ins and additional tools we'll use in this tutorial.
Checking In this tutorial, we want you to explore using a Of course, you'll need to start
Installation valuable web service testing plug-in for NetBeans NetBeans first. You may
have a GlassFish ESB
of the created by eviware.com. It has much of the same desktop shortcut or just use
soapUI Web functionality as their soapUI desktop application. It's the Windows Start menu
Testing very popular with web service developers. We need option.
Plug-In to check to see if it is installed in your environment.
You can also execute the
start_netbeans.bat in your
In NetBeans, access the Plugins management C:\GlassFishESBv21
window by using the Tools / Plugin menu bar option. directory.
The Plugins window displays.
- 9 of 99 -
After download is complete, select the Downloaded
tab and click the Add Plugins button.
Browse to where you downloaded the plug-in and For me, the download landed
select it. Then, click the Install button: on my Desktop.
After restart, use the Tools / Plugins menu bar Let's make sure that the plug-
option to again display the Plugins window. in was installed successfully.
- 10 of 99 -
Download- In this tutorial, we will want a convenient way to look Here's what the Hermes
ing at the contents of JMS queues. HermesJMS is an website has to say about
HermesJMS:
HermesJMS open source tool that I think you will find quite “HermesJMS is an extensible
handy. Let's download it. console that helps you interact
with JMS providers making it
easy to browse or search
Go to the Hermes JMS homepage at: queues and topics, copy
http://www.hermesjms.com/confluence/display/HJMS/Home messages around and delete
them. It fully integrates with
JNDI letting you discover
Find the link to the latest stable version and click on administered objects stored,
the link to go to Sourceforge: create JMS sessions from the
connection factories and use
any destinations found.”
- 11 of 99 -
Configuring In order to use the tool with our environment, we If you have trouble starting
HermesJMS need to do some configuration. Let's do that now. HermesJMS, make sure your
JAVA_HOME variable is set
appropriately since it is used
Make sure your JAVA_HOME property is set to point in the hermes.bat file that
to your JDK 6 installation. starts the program. My
JAVA_HOME is set to:
C:\Program Files\Java\jdk1.6.0_10
Use Start / All Programs / HermesJMS / Hermes to
start HermesJMS on Windows. You can also start it
by executing the hermes.bat file in the C:\Program
Files\HermesJMS\bin\ directory. The HermesJMS
window displays.
- 12 of 99 -
For Classpath group name, enter:
JavaMQClasspathGroup
Click OK.
- 13 of 99 -
Click Open. When prompted, allow Hermes to scan
for connection factories by clicking the Scan button.
Select OK to close the Preferences window. The savvy reader will wonder
in a moment while we are
closing the Preferences
window here just to open it
up again right away. We'll,
that's just how I got things to
work! It seems that
HermesJMS has a few rough
edges. I found that if you
don't follow this sequence,
things just don't work
smoothly. Bear with me.
- 14 of 99 -
We need to configure the JavaMQ session so it can
interact with the GlassFish JMS messaging broker.
Select com.sun.messaging.QueueConnectonFactory
from the Class pull-down menu:
- 15 of 99 -
We need to configure access to two queues
(qFinanceOut and qErrorOut ) that we'll use in the
tutorial. So, right-click on JavaMQ and select New /
Add queue:
Add a queue with Name: qFinanceOut Press Enter Remember to press Enter
to record the name. Click OK to finish configuring after adding or editing a field.
Otherwise, your data entry
access to the queue. may not “stick.”
- 16 of 99 -
The two sample entries (examples.xml and fix.xml)
still appear in the hierarchy under JavaMQ. Right-
click on each and select Delete to remove them from
the list:
- 17 of 99 -
Project 1: Creating Shared Components
We will create a number of WSDL documents and XSD schemas that we will want to share
across several projects. A best practice is to create these in a separate “common” project and
then import references into other projects as they are needed. In this project, we will build these
shared artifacts that we'll use later as we build the Supplier and Purchaser processes.
- 18 of 99 -
For Project Location, make sure to specify:
C:\MyBPELTutorial
- 19 of 99 -
Creating a Sometimes on a project, you find yourself having a
Common collection of common WSDL and XSD documents
Project that you want to manage as a group. One useful
technique is to create a “common” project to house
them. When you need them in another project, you
can import the artifacts in from the common project.
A “common” project can be of any type, but let's Why choose a web
create a web application project to store our WSDL application module if any
and XSD artifacts in this demonstration lab. type will work? Well, there is
no particular reason.
Use the File / New Project / Java Web / Web
Application to create a new project with Project
Name: CommonComponents
We have two basic schema documents we need to We'll import the XSD into our
build and store in the common project. One will WSDL document so we'll
specify the structure of a purchase order (PO). The have the data definitions we
need. It is good practice to
other specifies the details for a delivery notice (DN). define your data types in an
XSD instead of embedding
We won't need the index.jsp page, so click on the X the definitions into your
in the index.jsp tab in order to close it: WSDL. That way, you can
reuse the data type
definitions by importing the
XSD into several WSDL
documents.
- 20 of 99 -
Let's create an XSD by right-clicking on the If you have previously
CommonComponents node and using the New / created an XSD in your
NetBeans installation, you'll
Other / XML / XML Schema sequence. The wizard find a New / XML Schema
is invoked. Click Next. option and that's quicker than
New / Other / XML route.
For File Name, enter: PO and click Finish. The new
PO.xsd file appears in the Projects panel under
Source Packages and the XSD editor is opened.
This is a pretty typical
purchase order data
structure. The PO has
Building the We could create this XSD from scratch using the attributes for PONumber,
PO Schema graphical editor, but that would take a bit of time. PODate and Items. There
We could also import it from someplace on your can be an unlimited number
disk. However, we want to keep this tutorial self- of Item entries contained in
Items. For each Item, we
contained with no separate exercise files required. see attributes for
So, the XSD is provided below to copy and paste. ItemNumber and Item
Quantity.
Click on the Source control in the XSD Editor, delete
the current content and copy/paste the following
statements into the XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://MCZ01:14000//PO"
targetNamespace="http://MCZ01:14000//PO"
elementFormDefault="qualified">
<xsd:element name="PO">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PONumber" type="xsd:integer">
</xsd:element>
<xsd:element name="PODate" type="xsd:string">
</xsd:element>
<xsd:element name="Items">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Item" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ItemNumber"
type="xsd:string">
</xsd:element>
<xsd:element name="ItemQuantity"
type="xsd:int">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
- 21 of 99 -
This looks like a pretty typical XML schema After you copy and paste the
definition. Click on the Schema control and use the XML statements and are still
in the Source view, use the
Tree view tool to explore it: Alt-Shift-F feature to reformat
the statements. It makes for
much easier reading of XML.
Building the Let's build the second XML schema definition, this Sometimes you'll see that the
Delivery time for delivery note. Save All control is grayed
out. This indicates that no
Note changes have been made
Schema Again, right-click on the CommonComponents node since that last save.
and use the New / XML Schema option to start the
wizard. You might notice that you
don't need to take the New /
For File Name, enter: DN and click Finish. The Other / XML route to find the
XML Schema option. Since
new XSD node appears in the under Source you have already exercised
Packages node and the XSD editor is opened. it, the option appears earlier
in the menu sequence. You
can use File / New / XML
Schema instead. However,
you can still find it at New /
Other / XML too.
- 22 of 99 -
As before, click on the Source control in the XSD The structure of the DN is
Editor, delete the current content and copy/paste the very similar to that of the PO.
following statements into the XSD Editor:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://MCZ01:14000//DN"
targetNamespace="http://MCZ01:14000//DN"
elementFormDefault="qualified"
>
<xsd:element name="DN">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PONumber" type="xsd:integer"/>
<xsd:element name="Items">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Item" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element
name="ItemQuantity"
type="xsd:int">
</xsd:element>
<xsd:element
name="ItemNumber"
type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryDate" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
- 23 of 99 -
In the Source mode of the XSD editor, review the
structure of a delivery notice:
<xsd:element name="DN">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="PONumber" type="xsd:integer">
</xsd:element>
<xsd:element name="Items">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Item" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ItemQuantity" type="xsd:int">
</xsd:element>
<xsd:element name="ItemNumber" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeliveryDate" type="xsd:string">
</xsd:element>
...
- 24 of 99 -
Here is a sample DN record:
1001|101^11~102^12~103^13|2008-10-04Y13:45:50.123456+10:00
- 25 of 99 -
View your XSD in Schema mode and Column view.
- 26 of 99 -
For each level, click in its row and select the Add
Delimeter button and and fill-in the Bytes cell of each
row as shown below:
- 27 of 99 -
Testing Let's test the encoding/decoding by right-clicking on
Decoding of DN.xsd in the Projects panel and selecting
Delivery Encoding / Test. The Test Encoding window
Notices appears.
You see sections for Decode and Encode. Decode Decode means: delimited
means converting from non-XML to XML while record --to-> XML
Encode converts in the other direction: Encode means: XML --to->
delimited record
- 28 of 99 -
Use Alt-Shift-F to reformat the generated XML file
and see that the flat file structure was successfully
decoded into XML:
On the XML Source File field, browse to the new This is the directory where
DN.xml file that was just created in the the DN.xml file was just
created by the Decode
C:\MyBPELTutorial\CommonComponents\src\java operation.
directory, select it and click Open.
- 29 of 99 -
Organizing Our next task is to create the WSDL document that OK. I've got to come clean
Your XSDs defines the contract to send purchase orders in from on something. You may ask:
“Why all this work to
the web storefront. However, before we do that, let's reorganize the PO and DN
reorganize the files under the <default package> documents? Seems like a lot
under Source Packages. of extra work we could skip.”
Let's create two new named packages, one for POs Well, as I tested with
GlassFish ESB v2.1 Release
and one for DNs. Then, we'll move the documents Candidate 2, I couldn't build
to their appropriate packages. the WSDL in the next step
while the related XSD was in
Right-click on Source Packages and select the the <default package>. If I
New / Java Package option. For Package Name, moved it out of that package,
WSDL creation worked as
enter: PO and click Finish. A new package, named expected. So, I added this
PO, now appears under Source Packages. Organizing Your XSDs topic
so you would be successful.
Perform the same steps to create another new Java
package called DN: Hopefully, in a future revision
of the tutorial (and software),
I can remove this section.
- 30 of 99 -
Now, let's move the three DN-related files under the
new DN Java package node.
- 31 of 99 -
Creating With our PO and DN-related files organized, let's
WSDL for focus on the purchaser side and create the WSDL
Purchase document that defines the contract to send purchase
Orders orders in from the web storefront.
- 32 of 99 -
Click OK to select the PO element. This dismisses
the Select Element or Type window.
- 33 of 99 -
Click on the Partner control to display a more
graphical representation of the WSDL.
- 34 of 99 -
Project 2: Building the Supplier Application
In this project, we'll focus on the Supplier Process shown in the diagram below. It will receive
POs from the Purchaser Process and send back delivery notices (DNs). We have already
created the Common_POIn_SOAP.wsdl to describe the one-way, inbound message that
delivers a PO to the Supplier Process. We'll use that WSDL here.
When the Purchaser receives and processes the PO message, the Supplier must create a DN
that contains item number and quantity information from the PO. Then, it delivers the DN, in a
delimited flat file record, to the file system where the Purchaser can find it. In “real life,” the
Supplier and Purchaser wouldn't have access to the same file system and an FTP transfer would
be required.
Creating the Close all the tabbed windows that may be open from To quickly close all tabbed
Supplier Project 1 work. Also, collapse the windows, right-click on a tab
Project CommonComponents hierarchy in the Projects and select Close All
panel to reduce the clutter. Documents.
- 35 of 99 -
Adding We want to add references to the XSD and the These steps work well for
References WSDL documents we created in our “common” Windows. However, we have
noticed that on other
to the project so we can use them in our new project. platforms, like OpenSolaris,
Project you need to instead copy all
So, right-click on the Referenced Resources node the referenced items from
under Supplier and select Add / Project Resource. CommonComponents
hierarchy and paste them
into the Supplier hierarchy.
In the pop-up window, browse to Just highlight the nodes to
CommonComponents / src / java / DN and click to copy in the Projects panel,
select DN.xsd. Then, click Open to add a copy them to the system
reference to the XSD to your project. buffer, click on the Supplier
project and paste.
Perform the same steps to add a reference to the
PO.xsd file.
- 36 of 99 -
For File Name, enter: DNFromSupplier_%d.txt and %d is a pattern that will
for Path, enter: C:\MyBPELTutorial cause the File BC to insert a
sequential integer in the file
name.
For Payload Processing, select encoded data in the
Message Type drop-down list and click on the ...
icon at the XSD Element/Type field to reference your
DN schema element:
- 37 of 99 -
Click Finish to complete the WSDL definition. The
new WSDL document appears in the Projects panel
hierarchy and it is opened in the editor.
- 38 of 99 -
The Create New Partner Link window appears. For
Name, enter: POIn Click OK to dismiss the window.
Thanks to the two partner links, the “channels” are in “Channels” isn't a term that
place for our BPEL process to communicate outside BPEL purists would use, but I
the BPEL engine. found the notion of a partner
link hard to comprehend at
first. I started thinking about
them as a way to “tunnel out”
of the BPEL engine to get to
the outside world. The term
“communication channel”
helped me.
- 39 of 99 -
Drag a Receive element and an Assign element It is best to rename elements
from the palette and drop them onto the canvas at added to the model so that
their labels have real
an insertion point just below the Process Start node. business meaning. We are
taking shortcuts here by
We need connect Receive1 with the POIn partner leaving labels like Receive1
line and to define a variable in the POIn partner link and Assign1 stand. So, do
that is to contain the PO data. as we say, not as we are
doing here.
- 40 of 99 -
Your model looks like this:
- 41 of 99 -
Let's define a variable in the DNOut partner link that
is to contain the DN data. So, as you did earlier for
Receive1, click on the pencil Edit edit icon above
Invoke1 to display the Property Editor window.
- 42 of 99 -
Specifying We now have PO data coming in as SOAP over
Logic for HTTP through the POIn partner link using the HTTP
the Supplier BC. We are invoking the File BC to write out DN We haven't yet actually
BPEL data via the DNOut partner link. We now need to declared which binding
components will be used as
Process map the PO input data to the outbound DN data. our communication proxies to
Here's where the graphical Mapper is very handy. world outside the BPEL
engine, but you'll see later
Double-click on Assign1 to display the Mapper. that these are the defaults
Make the assignments as shown below by dragging that will be offered as we use
the CASA Editor to configure
from the inputs (on the left) to the outputs (on the our service assembly prior to
right). Map the PONumber from inputs to outputs: deployment.
- 43 of 99 -
We need to map the DeliveryDate from source to Clicking on the target first is
target. So, click on DeliveryDate in the right (output) important. That click
activates what I call the “blue
panel. mapping lane.” This is the
area where you can add a
Notice that the DeliveryDate “blue mapping lane” is menu element like Current
highlighted: Date & Time and have it
effect the target. If you don't
select the target first and see
the blue mapping lane before
adding a menu element, the
mapping won't work.
- 44 of 99 -
All the red notations you may have seen in the
canvas earlier has disappeared as we have
addressed all unspecified details so far:
- 45 of 99 -
We will use the BPEL ForEach construct to Here is how the tool's online
designate the loop. help introduces ForEach:
“Repeatedly executes the
activities contained inside a
Drag a ForEach element from the palette and drop it Scope activity N+1 times, where
onto the canvas right below Assign1: N equals the Final Counter
Value minus the Start Counter
Value.”
- 46 of 99 -
Click on Start Value at the right to display the blue Unlike in Java, array
mapping lane. We want to start our loop at 1 so processing begins at element
1 instead of 0 in BPEL.
click on the Number menu item and select Numeric
Literal. A Numeric Literal element is added to the
mapping lane.
Notice the small asterisk (cog wheel) beside Item on The asterisk indicates a
the left side. This indicates that it is a repeating repeating group (think array).
group of data.
- 47 of 99 -
Save All your work.
Add an Assign node inside the ForEach1 loop: This is where we will do
mapping of the repeating
Item data.
Creating a We'll need to define predicates to produce an The Help / Help Contents
indexed list of Item data that over which we can menu bar option was helpful
Predicate for the term “predicate.” I
loop. Getting access to an element in a repeating learned the following:
group is really a “side effect.” Predicates are – A predicate applies a
comparators expressed as a condition. They do condition to a node that
filtering and provide a subset of records to be can have multiple values.
processed in subsequent logic. – The result of a predicate
application is a subset of
data that satisfies the
Expand the vDNOut structure on the input (right) condition.
side of the Mapper to find the Item node. Click on – Once I create predicate, I
Item to display its blue mapping lane. Then right- can use it in an
click on Item and select Add Predicate: assignment to map
sources to destinations.
– Predicates are
constructed with XPath
functions.
- 48 of 99 -
Perform the mapping as shown below to specify the Not much of a “condition,”
predicate: right? Again, we are using a
predicate here for its “side
effect” of giving us an
indexed data structure that
we can iterate over.
- 49 of 99 -
So, just like you did above, add a predicate to Item Click on Item to display its
(under sPOIn / Items) on the left side. blue mapping lane. Then
right-click on Item and select
Add Predicate.
In the Predicate Editor, perform the same
ForEach1Counter --> Predicate mapping:
- 50 of 99 -
Exploring Click on the Source control and scroll down to see
the ForEach the BPEL statements that were created as you built
Loop BPEL the ForEach loop using the graphical editor. You'll
Syntax see that we have the intended side effect of indexed
references to the repeating group of Item data:
Notice that the $ForEach1Counter variable is the The indexing syntax looks a
index on the copy statements. bit like that for processing
Java arrays: Item[index]
- 51 of 99 -
Validate the XML to make sure it is correct. Validate XML:
- 52 of 99 -
Creating the To deploy any JBI module, you have to include it in Troubleshooting Tip:
Supplier a composite application. So, create a new Something odd happened to
me that you might encounter
Composite composite application by selecting File / New Project sometime. I tried to select
Application / SOA / Composite Application Build, but it was grayed out. I
was puzzled. I looked in the
The wizard appears. Click Next. bottom right of the NetBeans
window and saw a red icon. I
clicked on it and learned that
For Project Name, enter: SupplierCA there had been error
somewhere inside the IDE. I
Click Finish. The CASA Editor canvas appears and exited NetBeans and
you see that your SupplierCA has been added to restarted it. Then, the Build
the Projects panel. option was available.
If you double-click on
supplier node inside the
BPEL module (see above),
the BPEL modeling canvas
will appear so it's easy to
interrogate the contents of a
JBI module.
- 53 of 99 -
Save All your work.
- 54 of 99 -
Creating a The soapUI web service testing tool is a very
Web Service valuable addition to your NetBeans environment. If
Testing you aren't sure you have installed it, go to the We can't use the built-in web
Project Project 0 section and follow the steps there. We'll service tester in NetBeans as
our input is a rich XML data
use it now to exercise the bpSupplier BPEL process structure. The soapUI plug-
we just built. in makes it easy to test with
rich structures like a
In the Projects panel, create a new testing project by repeating group of items.
using the File / New Project / Java EE / Web Service
Testing Project sequence. Click Next to advance
the New Project wizard.
“WSTP” stands for “web
For Project Name, enter: SupplierWSTP service testing project.”
For Initial WSDL (URL/file), browse to and select The initial WSDL defines the
C:\MyBPELTutorial\CommonComponents\src\java\C structure of the message that
ommon_POIn_SOAP.wsdl, select it and click Open. will be sent to the Web
service endpoint you will
specify to soapUI a bit later.
Click Finish to end the New Project wizard. The
Import WSDL window appears announcing that the
wizard has “Successfully imported 1 Interfaces from
WSDL.” Click OK.
- 55 of 99 -
Testing the We need to edit Request 1 so it contains some data
Supplier that tests the supplier web service's ability to accept
Application a PO and generate a DN.
- 56 of 99 -
Before we send this XML to the supplier's web
service endpoint, we need to address the default
contents of the target URL field:
- 57 of 99 -
Expand the drop-down list at the top of the soapUI
testing window and select the Edit Current option:
Click OK.
- 58 of 99 -
Click in the right-side, response panel and see that it
is empty. Click on the Raw tab in the response
panel and see that the request was received
successfully:
- 59 of 99 -
In Supplier_DNOut_FileEncoded.wsdl in the
common project, you specified the file name and the
directory where the File BC should write:
- 60 of 99 -
Moving the Before we declare victory on the Supplier side of our
DN Internet store front application, let's tweak where the
Destination “DNFromSupplier_%d.txt” file is to be written.
Directory
for Testing Why? Here is the situation. When we create the
purchasing application, it will send the web service
request (that we just sent using soapUI) and, then, it
will constantly watch the file system directory to look
for delivery notices.
So, we'll “tell” the supplier system's File BC to write Of course, before going “into
the DN into a staging directory. Then, during production,” we'd undo the
change so that the interaction
testing, we will manually move it to between purchaser and
C:\MyBPELTutorial to let the purchaser find it. That supplier happens
way we have control over testing. instantaneously.
- 61 of 99 -
Redeploy your SupplierCA application by right- Notice that we didn't first
clicking on it and selecting Deploy. Build the Supplier and then
Build SupplierCA before
selecting Deploy. The Ant
Return to the Web Service Testing panel and scripts that drive deployment
resubmit your Request1. Check in the comprehend the
C:\MyBPELTutorial\fromSupplier directory to see dependencies between
that a DNFromSupplier_0.txt file has been created deploy and build. If modules
need to be built before the
there. composite application is
deployed, the Ant scripts take
We now have the File BC writing to a directory that care of this automatically.
our purchaser application won't be able to “see.” So,
that way we can manually move the file and watch
the purchasing application process it.
- 62 of 99 -
Project 3: Developing the Purchaser Application
In the last project, we completed the Supplier Process. It performs two chores. First, it accepts
POs as incoming SOAP payloads. Second, it creates a DN as a delimited flat file record and
writes it to the file system. The illustration below should help remind you where we've been and
where we're going.
In Project 3, we'll focus our attention on the Purchaser Process that will do four chores. First, the
it accepts SOAP requests from the Internet Shop Front and produces a PO. Second, it sends
the PO to the Supplier Process as SOAP over HTTP. Third, it looks in the file system for the DN
record from the Supplier Process. This DN acts as an acknowledgement of PO receipt and
processing. Fourth, the Purchaser Process sends notification to Finance via a JMS message.
As with the Supplier Process, the Purchaser Process will be orchestrated by a BPEL process.
This BPEL process will be more sophisticated and interesting than the last one we built. The
most interesting parts are: asynchronous events and correlation. When the Purchaser Process
is first invoked for a sale made at the Internet Shop Front, it instantiates the business process for
the PO data being received. That business process instance sends the PO to Supplier Process.
Then, it just sits there. This isn't a blocking call to the Supplier Process as the purchaser process
instance can continue processing. In other workds, it is an asynchronous call, not a synchronous
one.
While that purchaser process instance is just sitting there waiting, a bunch of new POs can be
delivered from the Internet Shop Front each instantiating its own business process instance.
Then, when the Supplier Process finally gets around to delivering the DN back to the Purchaser
Process for a particular PO, the Purchaser Process needs to determine to which business
process instance that particular DN applies. This is called “correlation.” The combination of
asynchronous processing and correlation shows off one of the most important features of a
BPEL engine – support for long-lived business transactions.
- 63 of 99 -
Let's tidy things up a bit. Close down all open To quickly close down all the
tabbed windows and collapse all projects in the tabbed windows, just click on
one of the tabs and select the
Projects panel. Close All Documents option.
Creating the Use the File / New Project / SOA / BPEL Module
Purchaser sequence to create a new BPEL project with Project
BPEL Name: Purchaser
Project
Click Finish to add the skeleton project to the
Projects panel.
Adding As we did in the last project, we want to add Note: These steps to add
References references to the two XSDs we created in our references work well for
to a Project “common” project so we can build WSDLs in our Windows. However, we have
new project that reference them. We also want to noticed that on other
platforms, like OpenSolaris,
add a reference to the WSDL file as we'll will need it you need to copy all the
in our BPEL process. So, right-click on the referenced items from
Referenced Resources node under the new CommonComponents
Purchaser node and select Add / Project Resource. hierarchy and paste them
into the Purchaser hierarchy.
Just highlight the nodes to
In the pop-up window, browse to copy in the Projects panel,
CommonComponents / src / java / DN and click to copy them to the system
select DN.xsd. Then, click Open to add a buffer, click on the
reference to the XSD to your project. Purchaser project and paste.
- 64 of 99 -
For Binding, select SOAP (the default) so we will
use the HTTP BC to process the data.
Our WSDL is complete. It defines how to accept If the Save All tool at the top
of the window is grayed out,
POs via SOAP over HTTP. there is nothing that needs to
be saved right now.
- 65 of 99 -
Construct- Let's turn our attention to the WSDL that defines the
ing WSDL to interface to allow our Purchaser Process to receive
Accept DN DNs from the Supplier Process via the file system.
from
Supplier Right-click on Purchaser and use the New / WSDL
Document sequence to create a new WSDL with a
File Name of: Purchaser_DNIn_FileEncoded
For Polling Directory, enter: C:\MyBPELTutorial “%” indicates that the file
name is a pattern and that, in
place of the “%”, we expect
For Message Type, select encoded data from the to see a number. So,
drop-down menu to indicate that the DN data DNFromSupplier_1.txt might
coming in is from a flat file delimited record. be a file that we'll pickup.
Click OK.
- 66 of 99 -
In the Encoded type field, enter: customencoder-1.0
Click Finish.
This completes the WSDL definition that describes Much of the data in legacy
systems are in encoded
how to get flat file delimited DN records from the file format. So, the main role of
system and convert them to XML documents. encoders is to bridge the gulf
between legacy and modern
systems.
- 67 of 99 -
After the Purchasing Process has “matched up” a
PO from the Internet Shop Front (store front) with a
DN from the Supplier Process, it needs to send a
confirmation to Finance. Now, let's create WSDL
that defines this interface between the Purchasing
Process and Finance.
- 68 of 99 -
Construct- Things can conceivably go wrong and we have to be
ing WSDL to able to handle errors. In our scenario, if the
Record Purchaser Process has sent a PO to the Supplier
Processing Process and has not received a corresponding DN
Errors back within a reasonable time period, this is a
processing error. To record the error, we are to
write a message to an error queue that can be
investigated by purchasing staff. So, let's create the
WSDL that defines the interface between the
Purchasing Process and that error queue.
- 69 of 99 -
These WSDL interface definitions are ready to be
the basis for partner links in our purchasing BPEL
process:
Adding Let's add all our partner links to the process first so
Partner we have our “channels” in place to communicate
Links with the world outside the BPEL engine.
- 70 of 99 -
A new partner link is added to the canvas. Rename
it by double-clicking on the default name
(PartnerLink1) and entering POIn
- 71 of 99 -
And finally, create the channel out for Errors by
dragging the Purchaser_ErrorOut_JMS.wsdl to the
right side of the model and dropping it under
FinanceOut.
Specifying All the partner links are in place. Now, let's add the
Logic for Receive node so PO information can come into our
the business process from the Internet Store Front.
Purchaser Drag and drop a Receive element from the palette
BPEL into the model. Receive1 is added to the canvas:
Process
- 72 of 99 -
Connect Receive1 to the POIn partner link by finding
the little gray envelope decoration on Receive1,
clicking on it and dragging it to the envelope on
POIn:
- 73 of 99 -
Drag in an Invoke element from the palette and drop
it below Receive1.
Click on Invoke1 to find the
As you connected an element to a partner link little gray envelope icon.
above, now connect Invoke1 to POOut so the PO is Drag this little envelope and
sent along to the Supplier. drop it onto the big envelope
of the POOut partner link.
And as before, click on the pencil icon, this time for
Invoke1 and specify an input variable named:
vPOOut
- 74 of 99 -
Double-click on Assign1 to display the Mapper.
- 75 of 99 -
Adding Drag a Pick element from the palette and drop it
Support for onto the canvas and drop it right after Invoke1:
Asynchro-
nous
Processing
- 76 of 99 -
The OnMessage path has a receive activity that can
bring data in via a partner link channel. We need to
connect it to the DNIn partner link so that the
delivery notices can come into our process
asynchronously.
- 77 of 99 -
Double-click on the Message receive element and Message receive element:
create an Input Variable named: vDNIn
- 78 of 99 -
Connect Invoke2 to FinanceOut: You know the drill. Find the
little gray envelope icon on
the Invoke, drag it and drop it
on the big envelope on the
partner link.
- 79 of 99 -
To finish the OnMessage path, we need to map
inputs into the Invoke2. So, double-click on Assign2
to display the Mapper.
- 80 of 99 -
Now, “wire up” the PO and DN inputs to the two Do
Marshal elements and wire up the Do Marshals to
the Concat as shown below.
Using the Mapper was sure easier than coding the Notice in this screen shot that
BPEL syntax! The Source and Design views are the BPEL Editor is enlarged
to provide maximum “real
kept in-synch so, you can make edits in either place. estate” for editing. It's easy
For example, if you forgot to include the space after to maximize and minimize a
the colon (in “... process this order: “), it might be tabbed window in NetBeans.
quicker to make the edit in Source mode. Just double-click on its tab.
- 81 of 99 -
Save All your work.
- 82 of 99 -
To finish up the OnAlarm path, we need an Assign
and Invoke pair to establish data and interface with
the Error Queue via the ErrorOut partner link.
Again, I am showing an
undocked window. To
undock a window, right-click
on its top border and select
the Undock Window option:
- 83 of 99 -
To complete the linkage between Invoke3 and
ErrorOut, we need to specify an input variable. So,
double-click on Invoke3. For Partner Link, make
sure that ErrorOut is selected from the drop-down
list. Establish an Input Variable called: vErrorOut
- 84 of 99 -
Save All your work.
- 85 of 99 -
Defining a Correlation is a powerful feature of a BPEL engine.
Correlation It allows it to tie together a process instance created
earlier with a new incoming message that should be
processed by that instance. Correlation is
fundamental to support for long-lived transactions.
The original process instance might be created
today and a new message for it might arrive a week
from now. The engine associates the message with
the appropriate instance that initiated the original
external interaction that resulted in the inbound
message.
The message is:
Let's ponder the warning message we just saw. The “WARNING: Activity does not
have correlations defined on
tooling sees that we have two receives in our model: it.”
- 86 of 99 -
Click Next to move the wizard forward to the Define
Correlation step. A Mapper appears.
Click Finish to close the wizard window. Now, the BPEL engine will
match messages coming into
the OnMessage with the right
Now, Validate XML again and watch in the Output existing business process
Panel to see that no errors are left to correct. The instance based upon
earlier warning we saw about missing correlation matching values of the
has disappeared. PONumber fields in the PO
and DN messages.
- 87 of 99 -
Create a new composite application by selecting the
File / New Project / SOA / Composite Application
sequence.
Drag the Purchaser node from the Projects panel This is how you tell the CASA
into the JBI Modules section of the open CASA Editor what service units you
want added to the service
Editor canvas. assembly.
- 88 of 99 -
Save All your work.
- 89 of 99 -
The test case wizard starts.
“TC” for “Test Case” and
For Test Case Name, enter: TC2001 “2001” as that is the PO
Number we'll supply in the
Click Next to move on to pick the WSDL interface test case.
through which we want to pass a SOAP test
message.
There is only one operation in the WSDL, so click on I have noticed that the test
case may not appear under
it (Purchaser_POIn_SOAPOperation) and select the Test node so it looks your
Finish. The new test case appears under Test in the test case wasn't created. If
Projects panel. you see that, just create
another test case with a
A skeleton message request has been created by different name. Then, you'll
see two test cases appear
reading the WSDL: including your original
TC2001 case. Then, just
delete the second one you
created. Looks like a bug.
Hope this workaround works
for you.
- 90 of 99 -
Replace the skeleton test case with the following
XML statements:
<soapenv:Envelope
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:po="http://MCZ01:14000//PO">
<soapenv:Body>
<po:PO>
<po:PONumber>2001</po:PONumber>
<po:PODate>2008-09-11T12:13:14.567890</po:PODate>
<po:Items>
<!--1 or more repetitions:-->
<po:Item>
<po:ItemNumber>201</po:ItemNumber>
<po:ItemQuantity>21</po:ItemQuantity>
</po:Item>
<po:Item>
<po:ItemNumber>202</po:ItemNumber>
<po:ItemQuantity>22</po:ItemQuantity>
</po:Item>
<po:Item>
<po:ItemNumber>203</po:ItemNumber>
<po:ItemQuantity>31</po:ItemQuantity>
</po:Item>
</po:Items>
</po:PO>
</soapenv:Body>
</soapenv:Envelope>
- 91 of 99 -
When the test case appears, edit it so it contains
these XML statements:
<soapenv:Envelope
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/
http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:po="http://MCZ01:14000//PO">
<soapenv:Body>
<po:PO>
<po:PONumber>3001</po:PONumber>
<po:PODate>2008-09-10T12:12:12.34567</po:PODate>
<po:Items>
<!--1 or more repetitions:-->
<po:Item>
<po:ItemNumber>301</po:ItemNumber>
<po:ItemQuantity>31</po:ItemQuantity>
</po:Item>
<po:Item>
<po:ItemNumber>302</po:ItemNumber>
<po:ItemQuantity>32</po:ItemQuantity>
</po:Item>
</po:Items>
</po:PO>
</soapenv:Body>
</soapenv:Envelope>
- 92 of 99 -
Let's see if these steps ring true. In our testing, we
are “on the clock” since the OnAlarm branch waits
30 seconds for a matching DN. So, the clock is
ticking as we perform the following test steps. Make
sure you do all these steps within 30 seconds. Start
two Windows Explorers so you can easily view the
contents of the C:\MyBPELTutorial\fromSupplier and
C:\MyBPELTutorial directories. Now, in 30 seconds
to do the following:
- 93 of 99 -
Before we check the contents of our two queues and We are stalling here for 30
declare victory, let's review the overall application seconds without sending
along this latest
architecture to remind ourselves what should have DNFromSupplier text file so
just happened: the Pick “times out” and we
get an entry sent to our error
In the illustration below, we see that when the DN is queue.
received from the Supplier Process, the Purchaser
Process adds a message to the queue that Finance
watches for completed orders. Remember that we
established a timeout value of 30 seconds. So, if a
corresponding DN is not received within that
threshold, an entry is written to the error queue.
- 94 of 99 -
Viewing Use the Windows Start / All Programs / HermesJMS If you don't have HermesJMS
Contents of / Hermes sequence to start HermesJMS. installed and configured in
your environment, go to
JMS Project 0 to learn how to
Queues Since we have already configured HermesJMS in download, install and
Project 0, we can expand the sessions / JavaMQ configure it.
hierarchy and see our two queues:
You can also start
HermesJMS by executing the
hermes.bat file in
C:\Program
Files\HermesJMS\bin.
- 95 of 99 -
At the top of the message you can see the message
we included along with the PO and DN data:
Finance, please process this order:
- 96 of 99 -
Summary
Let's revisit the work we did in this module by reviewing the two diagrams that framed the
projects we tackled. As you recall from the illustration below, we initially set the stage with a
business conversation involving an Internet Shop Portal that encouraged customers to make
online purchases. A Back Office operation interfaces with the Supplier for order fulfillment and
with Finance for customer invoicing. To keep the scope of the tutorial manageable, we focused
two BPEL processes
only on building the Back Office (Purchaser) and Supplier capabilities.
With the business context understood, we began implementing the Supplier Process illustrated
below. To keep our technical scenario well-bounded, we ignored interactions with the Shipper.
Our Supplier Process work involved receiving a purchase order (PO) message via SOAP over
HTTP and generating a delivery notice (DN) as a delimited record written to the file system. We
got some good experience with the custom encoder capability that facilitates transformation
between delimited and XML formats.
- 97 of 99 -
Once the Supplier Process was completed and unit tested, we turned our attention to the
Purchaser Process which used BPEL asynchronous processing features to match POs from the
Internet Shop Front with the matching DN from the Supplier Process. We got additional
exposure to the custom encoder to transform the delivery notice from delimited form to XML.
One of the most interesting features of the Purchaser Process is how correlation is used to
match up of the right business process instance with its corresponding delivery notice based on
PO Number. The Supplier Process finished the scenario by writing a message to JMS queues
to direct further processing by Finance who coordinates customer invoicing and investigating
unmatched purchase orders.
On the next page, you'll find pointers to some references that to help you continue to learn about
the OpenESB-based technology.
- 98 of 99 -
References
Here are some references that may help you learn more about the concepts and product features
you explored in this module.
- 99 of 99 -