IIB10003 01 EmployeeService IntegrationService
IIB10003 01 EmployeeService IntegrationService
Creating an
Integration Service
Featuring:
January 2016
Hands-on lab built at product
Version 10.0.0.3
IBM Integration Bus V10 Workshop January 2016
1. INTRODUCTION ............................................................................................................................ 3
1. Introduction
An integration service is a specialized application with a defined interface and structure that acts
as a container for a Web Services solution.
In IBM Integration Bus, an integration service is a specialized application with a defined interface
that acts as a container for a Web Services solution:
Important note
This lab, version 10.0.0.3, has been updated significantly from earlier versions. The
following changes have been made:
You should use the Windows user "iibuser". This user is a member of mqbrkrs and mqm,
but is not a member of Administrators. The user "iibuser" can create new IIB nodes and
do all required IIB development work. However, installation of the IIB product requires
Administrator privileges (not required in this lab).
The database has been changed from the DB2 SAMPLE database to the DB2 HRDB
database. HRDB contains two tables, EMPLOYEE and DEPARTMENT. These tables have
been populated with data required for this lab. (The DDL for the HRDB is available in the
student10 folder; we intend to provide corresponding DDL for Microsoft SQL/Server and
Oracle over time).
The map node now retrieves multiple rows from the database, using an SQL "LIKE"
function . Additionally, the map has been refactored to use a main map and a submap.
Both the main map and submap are located in a shared library.
Input to the integration service is now a simple schema containing just one element, the
required employee number.
As a consequence, this version of the lab, and the associated solution, can only be used
with the corresponding changes in other labs. Use version 10.0.0.3 of all labs in this
series of lab guides.
The service accesses an external database and responds with data retrieved from the database.
You will need to configure IBM Integration Bus to work with an external database system. In this
lab, we are using DB2.
1. Configure the IBM Integration Bus default runtime node to work with DB2
a. Runtime configuration: Configure a JDBCProvider configurable service.
Configure the security credentials to work with the database.
b. Development configuration: Create a Database Definition project, and the
database connectivity configuration.
2. Create a Shared Library. This library will contain your message models, the WSDL that
defines the new service, and the map and submap for the service.
3. Create a Message Model
a. Create a message model based on a database table definition
b. Extend the message model with other schema available in the library
4. Create an integration service, and define the WSDL associated with it
5. Implement the integration service operation
a. Create the Submap that retrieves employee data from the EMPLOYEE table
b. Create the main Message Map in the Shared Library
6. Test the service using the Integration Toolkit Flow Exerciser
7. Test the integration service using external tools (optional)
a. Test the service using SOAPUI
2. Start the IIB Toolkit, using the shortcut on the Windows Start menu. Accept the default name
for the workspace (or you can specify your own location if desired).
When you start the Toolkit, a new IIB node named TESTNODE_iibuser will be created. This
node will be started automatically when the Toolkit starts. You will be able to see this node in
the Integration Nodes view of the Toolkit.
If the IIB Healthcare Pack product is installed, you will also see the Configurable Services
folder.
3. To run this lab, the Integration Bus node must be enabled to allow a JDBC connection to the
HRDB database.
Open an IIB Command Console (from the Start menu), and navigate to
c:\student10\Create_HR_database
Accept the defaults presented in the script. This will create the required JDBC configurable
service for the HRDB database.
6. Stop and restart the node to enable the above definitions to be activated
mqsistop TESTNODE_iibuser
mqsistart TESTNODE_iibuser
This section will not normally be required if you are running the lab scenarios on the pre-built
VMWare workshop image. If you are creating your own environment, you will need to run the
commands in this section. You may need to alter the database schemas and authorities in the
DDL to reflect your own environment.
The HRDB database, and the EMPLOYEE and DEPARTMENT tables have already been
created on the supplied VMWare image. If you wish to recreate your own instance of this
database, do the following tasks:
2. Open an IIB Command Console (from the Start menu), and navigate to
c:\student10\Create_HR_database
2_Create_HRDB_Tables
Appropriate database permissions are included in the scripts to GRANT access to the user
iibuser.
From the Start menu, click IIB Event Log Monitor. The Monitor will open; it is useful to have this
always open in the background.
Make sure you are logged in as "iibuser", and open the IIB Toolkit using the shortcut on the
Windows Start menu.
1. In the Toolkit navigator, right-click in blank space, select New, Database Definition.
4. Click Next.
If you wish, you can click Test Connection, to make sure you have specified the connection
details correctly.
Optionally, select save the password, and click Finish. (this is only required for subsequent
Toolkit access to the database connection; it is not used by the IIB runtime).
(You may need to expand the dialog window to see the Save Password checkbox).
(Note that the HRDB database has been defined with the IIBADMIN schema. "IIBUSER" has
been granted permissions on this database. For reference, this is shown in the script
2_Create_HRDB_Tables.cmd).
9. The database definition for the HRDB database is now present as a project in the
Independent Resources part of the navigator.
Note that this HRDB.DBM file can be used by any other developer requiring access to the
database. It contains a definition of the database, and the selected tables and schemas, and
can be shared as required, to create the related IIB schema definitions.
1. A Message Model is defined within a container called a Library, so you must first create a
Library. In the Navigator view, click New, and select "Start by creating a library".
2. You can choose whether to create a Shared or Static library. Choose Shared (the default),
and name the library EmployeeService_interface_and_maps.
Click Finish.
3. In this library create a new Message Model (click "New" under the library name), then select
"Message Model".
6. Select the HRDB.dbm file from the database definition project in the workspace (under
Independent Resources).
This will automatically create the XML Schema file name, HRDB.xsd.
Click Next.
7. Select the HRDB database, which will automatically select the EMPLOYEE and
DEPARTMENT tables.
8. The schema will be created, and the Toolkit will open it with the XML schema editor. Note
that the name of the schema is HRDB.xsd.
To do this, the Integration Service will pass a return code, plus details of any SQL messages, to the
requesting application. You will therefore import a second schema, DBResp, into the HRDB schema.
The DBResp schema contains several elements that can be used to report SQL responses, as well as
a user return code.
The HRDB schema will be augmented with a new complex type, EmployeeResponseType, which
contains the EMPLOYEE and DBResp types.
c:\student10\integration_service\resources
EmployeeService_interface_and_maps
In the Types pane, right-click in an open area, and select Add Complex Type.
7. Double-click EmployeeResponseType which will open the schema editor for this type.
9. The editor will add a default element using the first alphabetically available. Luckily, since
DBResp is the first available, this is the one that we want.
10. Now, add a second element reference, by right-clicking the EmployeeResponseType again.
11. To change this second reference, click the second instance of DBResp (click DBResp, not
DBRespType). A drop-down menu will be shown. Click Browse.
13. Since multiple rows might be returned from the EMPLOYEE table, it will be necessary to be
able to handle multiple instances of the EMPLOYEE element within EmployeeResponse, so
set the Multiplicity as follows:
When you've done this, the complex element will look like this (click the EMPLOYEE
element) (You may need to click in an open area of the editor to update the display of the
multiplicity).
The properties will look like this (note the minimum and maximum occurrences when the
EMPLOYEE element is selected):
14. Return to the high-level definition of the schema (click the highlighted icon shown below).
The Mapping Node bases its message inputs and outputs on element definitions, rather than
element types, so it is necessary to define a new element named EmployeeResponse.
16. Set the Type of the new element to EmployeeResponseType (right-click, Set Type, Browse).
Type "e" into the filter to reduce the list. Select EmployeeResponseType, and click OK.
1. For the purposes of this lab, a suitable schema has been provided, so copy/paste (or
drag/drop) this into the shared library.
This schema has no namespace, so will be imported into the (default namespace).
Click Next.
3. Expand the EmployeeService_interface_and_maps library for both input and output to the
map. Expand DFDL and XML Schemas.
Since this is a submap, you should use only "Type" definitions, not elements.
Click Finish.
4. The map editor will be shown, but no transforms have been made so far.
5. Since the shared library does not have a project reference to the HRDB.dbm project, click
the "Add database" link.
When HRDB appears in the pane on the lower right, click OK.
1. Select (tick) the EMPLOYEE table (note this will select all columns - you can select
individual columns if you want).
Note - only select the EMPLOYEE table, not the DEPARTMENT table. This function
is the generating the SQL SELECT clause.
2. Remove the "1=1" phrase from the "SQL where clause" pane.
IIBADMIN.EMPLOYEE.EMPNO LIKE ?
$employeeNumberType
The map will be built to retrieve all employee records that partially match the provided key.
For example, if the provided key is "0020", we want the map to retrieve rows with a value of
"000020", "00201", "00204", etc.
This is done by extending the SQL LIKE statement, in conjunction with the "%" character,
appended both as a prefix and a suffix. Hence the statement "SELECT xxxx LIKE %0020%"
will achieve the result described above.
Now double-check that you typed this XPath exactly as shown above !!
9. The map will be shown as follows. You will now see the Select input assembly showing in
the map editor.
(Note - you can return to refine the SQL statement by hovering over and selecting the
database icon, as below).
10. In the output message assembly, connect the Select transform to EmployeeResponseType.
Then, click "Select" to enter the next logical level of the map.
12. The "For each" transform will indicate a Warning, and suggest a "quick fix". Hover over the
light-bulb on the transform, which will show the available "quick fix".
13. Invoke the quick fix by clicking "Invoke automap". Since we simply want to map similarly-
named elements, you can accept the defaults here, and click Finish.
Expand DBResp, and connect the input ResultSet to the output DBResp/RowsRetrieved.
This will initially create a "For each" transform; the transform will show a warning.
16. Click the drop-down arrow on the transform, and change the transform to "Custom XPath".
17. In the map editor, make sure the Custom XPath transform is selected.
On the Properties tab for this transform, select "General" and type the following into the
XPath editor:
fn:count(
Then, invoke the content assist function (Ctrl-space) which will show you the possible values
for completion. Select the value that shows $ResultSet, or similar. Depending on whether
you have made other editing changes, the value shown may be $ResultSet or have a
suffixed number. The example shown below is $ResultSet.
Complete the XPath expression with a ")". This expression will calculate the number of rows
retrieved from the database.
Expand the output assembly DBResp, and right-click UserReturnCode. Select Add Assign.
19. The default value for an Assign is "0", so leave this unchanged.
20. The submap will now look like this. The submap is complete, so save (Ctrl-S) and close the
map.
2. Name the service EmployeeService, and accept the default to "Define it myself ...".
Since the schemas will be defined in a Shared Library, you should choose the option to store
the interface definition in a shared library. Select this option, and specify the name of the
EmployeeService_interface_and_maps.
Click Finish.
3. The following service editor will open and the following service interface will be generated.
The service will contain a request/response operation named operation1.
4. Note that the Library Reference of the new service has automatically been set to reference
the Library where the service schemas and will be defined (right-click the new Integration
Service and select Manage Library References).
6. Change the Type of the input message to employeeNumber. (Click the current value
"string"), then click Browse).
Click OK.
8. For the output message, use the same technique and select EmployeeResponse.
9. The getEmployee operation interface is now fully defined, and should look like this.
Note that the name of the input message will have been changed to employeeNumber. This
is because employeeNumber is an XSD element, and the "name" attribute is not permitted
when using an XSD element.
Similarly, for the output message, you have used an element (EmployeeResponse). You
could have used the element type (EmployeeResponseType), which would not have
changed the name of the operation types.
Click Next.
3. For both the map input and output, expand EmployeeService_interface_and_maps, and expand
DFDL and XML Schemas.
• For the input, select getEmployee (remember this originates from the input message of the
integration service, and resolves to element employeeNumber).
Click Finish.
4. The map editor will open. Expand both the input and output assemblies.
5. Connect the input employeeNumber to the output EmployeeResponse. This will produce a
Local Map.
A warning will indicate that there are no valid element mappings. We will resolve this by
changing the Local Map to a Submap.
The submap will show an error, since you haven't yet provided the name of the submap.
7. Highlight the submap transform, and locate the Properties of the transform.
Note - the map selection wizard will initially only show maps or submaps that are available for
use in the current context. The screen capture below has unchecked this option, enabling you
to see all maps and submaps, even though not all of these choices would make sense in the
current context.
You will see that the getEmployee operation is not implemented, so is greyed out. Click
getEmployee to implement it.
2. From the Transformation folder, drop a Mapping Node onto the flow editor.
Name it getEmployee_WS.
3. In the Properties (Basic) of the new Mapping Node, click Browse to select the map you created
earlier. Select the getEmployee_WS map in the Shared Library, and click OK.
4. The new map node properties will show the map in the Shared Library.
First, make sure that the node TESTNODE_iibuser is started. You can check this in the Toolkit
Integration Nodes pane. If it isn't started, right-click and select Start.
1. In the service editor, make sure the Service tab is selected. You will see a red button in the
top right of the editor pane.
2. Click the red button. The integration service will be deployed to the TESTNODE/default.
Note that if you have other nodes or servers running, you will be presented with a selection
dialogue.
When the service is deployed, you will see an information message. After reading this, select
the box to not see in the future, and click Close.
3. The flow editor will turn grey, indicating that the Flow Exerciser is ready for use.
In the top right, the available icons will have changed. Select the "Send message" icon (the
middle icon).
4. In the Send Message window, click the button to create a new message.
The Flow Exerciser will have automatically populated a template input message, based on
the WSDL and associated service operation input message.
In the employeeNumber element, change the value to 000010, and click Send.
6. The service operation will be executed. Highlighting the "Sending Message" line will show
the message that was sent to the service.
7. Highlighting the "Received HTTP" line will show the message returned from the service. Note
that the employee record for the selected employee number has been retrieved from the
EMPLOYEE table.
8. In the flow editor, you will now see that some parts of the service definition have turned
green. Click the "getEmployee" operation name.
9. In the flow editor, you will see the subflow that implements this operation. You will see that
the connectors are green, indicating that the message flowed down this path.
The message tree that was current at the time it passed through this connector will be
retrieved and displayed. Note that this is the full message tree, not just the user data.
You can expand various parts of the tree, such as LocalEnvironment, Environment,
ExceptionList, as well as the Message.
Note that the domain of the message tree is shown. In this case, it is XMLNSC.
11. Click the icon on the final connector. This time, you will see the message tree after the
employee record has been retrieved from the database.
Note that you can return to the first connector icon to review the message tree again, at that
point. The data is not discarded.
14. The returned message will contain two employees, both containing "0020" in the employee
number field.
RowsRetrieved = 2.
This time, select "Import from file". Using the File system button, navigate to
c:\student10\integration_service\data\employeeNumber 000012.xml.
16. Click Send, and use the same tools to review the test outcome.
17. You will see no rows have been returned, and the EMPLOYEE part of the message is not
present.
RowsRetrieved = 0.
Highlight the Service Query URL, and right-click and select Copy.
2. Open SOAPUI (on the Windows Start menu). Ensure you are using the SOAPUI workspace
EmployeeService_PrebuiltWorkspace.
Provide a suitable name of your choosing for the project (not one of the existing projects).
In the "Initial WSDL" field, paste the contents of the Windows clipboard.
Important - the Copy function included the text "Service Query URL" at the start of the
string, so this must be manually deleted.
Click OK.
3. Expand the new project, and open Request1. You will see that SOAPUI has pre-populated
the web service input with the required schema elements. In this case, these are derived
from the EMPLOYEE table.
Also note that the service port number has been set to 7800. This is the port number that has
been allocated for the TESTNODE default server.
4. Provide a value for the EMPNO element. We suggest using value 0020 (replace the ? with
this value, as shown).
5. Clicking the green arrow (top left), and the Integration Service should run and return the data
to the client, similar to this, depending on the number of rows retrieved.
6. Create a second SOAPUI request in the same project. This time, use the value 000012,
which does not exist in the EMPLOYEE table.
When you click the green arrow, you should see the response indicating that the flow
successfully accessed the tables (user return code 0), and no rows were returned
(RowsRetrieved = 0).