Testing newly deployed composite service.
Now we are ready to test the composite service.
Log onto the enterprise manager at:
Click open SOA->soa-infra->simpletutorial (or default
if you deployed the composite to that partition)
Click on VehicleStatus and select the tab called Test
Input test data to form fields
Write manually ABC-123 to the license_number field. And some
valid datatime for event time (e.g. 2012-11-10T10:10:10)
Finally press the Test Webservice button that is at the
bottom of the page.
If you’ve made a mistake in creating the data source and
connection pools, you will get an error about data bindings. Double check all
the names (and especially the lowercase- uppercase differences) in the datasource
and deployments part (done that – been there…).
Let’s check what happens if we use for a license plate that
does not exist in the database.
Clearly it is not working. So let’s add a little bit of
logic to handle the case of zero rows returning back from the select query.
First we need to add a variable to host the number of the
rows returned. If it is zero we will add a default return value.
In the BPEL editor there is a icon that looks like (x) on
the left side on the canvas. The tooltip for it is variables…
Click on it. Add a variable names RowCount and make it an
integer. You add variables by pressing on the green plus icon.
You can select the type of the variable by pressing the
magnifying glass icon.
Finally press Ok.
Next set the value for the variable. Drag and drop the
assign operation to the canvas before the “AssignReturnValue” operation, name
it “AssingRowCount” and double click it.
We need to set the RowCount. We need to do this with an
expression. Drag and drop the expression icon on top of the RowCount variable
on the right side of the “Copy Rules” operation.
This opens up an expression editor.
Open up the InputVehicleStatus_OuputputVariable until you
reach VehicleStatusCollection. Press the InsertIntoExpression button.
Remove the bpw:getVariableData part away. We will be
replacing this with another function.
We need to turn this into the rown count. This is done with
the BPEL XPath extension functions that you need to select on the functions
part. Take the cursor to the beginning of the Expression row and select the
countNodes from the BPEL XPath extension functions. Press the Insert into
Expression button. Move the closing ) to the end of the row and remove the
bpws:getVariableData function call. Your expression should be:
ora:countNodes('InvokeVehicleStatus_OutputVariable','VehicleStatusCollection','/ns3:VehicleStatusCollection')
We still turn this into number (from the Conversion
functions).
Note: You can skip this part also if you apply the
ora:CountNodes directly in the if statement which follows next.
Press Ok to close the dialog.
Last part to add is an if statement.
Drag and drop switch after the just added assignment.
Click on the first condition. Change label to zero rows.
Click on the condition button for defining the function. Insert rowCount into
the expression text area. Edit it to
bpws:getVariableData('RowCount') = 0
Press ok twice to close.
Note: You can shorten the above part and remove the
auxiliary variable (RowCount) completely if you apply the ora:CountNodes
expression directly here.
Add an assignment statement into the flow and double click
on it. Change assignment name to DefaultReturnNotFound.
Double click on it. Open OutputVariable on the right side
and drag and drop the expression icon on top of it. Add a default value there.
Close it.
Finally move the original return assignenment to the default
branch.
Now we are done. Save everyting by pressing the save button
or from file->save all.
Deploy again and test again
Test first with data that has a match in db (like ABC-123
license plate) and then when there is no data.
Hi Martti, excelent tutorials you are preparing, congratulations.
VastaaPoistaKeep in touch luiz.celeguim@gmail.com