Loan Approval
Introduction
This directory contains the files that make up the example loan approval BPEL process, two auxiliary Web services upon which it depends, two command-line test clients, and a BPEL process client JSP page. The loan approval process is the same as the one used in the BPEL specification Business Process Execution Language for Web Services Version 1.1.
The values sent to the BPEL process and returned by the assessor and approver are read from a configuration file. See The bpel_example_config.xml File below.
Dependencies
- You must have a working ActiveBPEL engine installation. The ActiveBPEL engine has been tested using Tomcat Version 5.0.28.
- You need Ant in order to run the targets in the build.xml file. You could do everything manually, but the rest of this document assumes you have Ant. The build.xml file was created using Ant Version 1.6.1.
- The environment variable CATALINA_HOME must be defined so the Ant script knows where to deploy everything.
Setup
If your ActiveBPEL engine installation is not running on "localhost:8080", change that string to whatever is appropriate in the following files.
- bpel_example_config.xml
- bpel_process/wsdl/loanapprover.wsdl
- bpel_process/wsdl/loanassessor.wsdl
Deploying the BPEL Process
From the command line, navigate to the directory installdir/loan_approval (where "version" is a version number like 0.9.5). All subsequent commands will be run from this directory.
Then run the following command.
ant deploy
The deploy target calls three other targets: deploy-bpel, deploy-ws, and deploy-jsp. deploy-bpel creates and installs a .bpr archive file that contains the BPEL process information. deploy-ws creates and installs a .wsr file that contains the Web services. deploy-jsp creates and installs a .war file that contains the JSP page and supporting classes.
When the ActiveBPEL engine sees a .wsr file in the bpr directory, it hands it over to Axis (a SOAP implementation). The Web services are independent of the BPEL engine.
Testing the Web Services
There is a simple command line client that tests the "assessor" and "approver" Web services. These services are used by the BPEL loan approval process. The test client calls each Web service and compares the returned result with the expected value found in the config file. To run the test client, type
ant ws-test-client
(The Web services themselves are deployed by the target deploy-ws as discussed above. However, the target ws-test-client does NOT depend upon the deploy-ws target. Why not? Because things happens too fast: if you deploy the Web services then immediately use the client the server may not have time to notice and (re)initialize the Web services. You must use either the deploy-ws or deploy targets before running the test client.)
(If you try to hot-deploy using the deploy-ws, Tomcat may get confused. You will see error messages in the Tomcat console. If that happens, just restart Tomcat.)
The command line test client's output is similar to JUnit output; if all is well, you will see
.. OK 2 tests; 0 errors
If one fails you will see something like
E. assessor expected result "low" does not match returned result "foo" ERROR 2 tests; 1 error
Web Services and the ActiveBPEL Engine
The Web services are deployed inside a .wsr file, a Jar file. This is not necessary; it is only a convenience. The ActiveBPEL engine will "notice" the .wsr file and hand our Web services to the Axis SOAP implementation. The engine does not "know" about the Web services directory and does not use any shortcuts to call the Web services.
It may take a while for the engine to notice the .wsr file. The default polling interval is 20 seconds.
Running the BPEL Process Client
To run a command-line client that calls the BPEL process Web service, type
ant client
The client compares the value returned by the BPEL process with the bpel_example_config.xml file's value /rundata/bpel-expected-response and prints either an OK or an ERROR message.
As discussed above in Testing the Web Services, you must deploy everything before using this client.
Using the BPEL Process JSP Client Page
Instead of running the command line clients, you can use the JSP page at http://localhost:8080/bpel_example_client_page/index.jsp. (Again, if your Tomcat installation is not running at localhost:8080, modify the URL accordingly.)
The page displays many of the values from the config file and lets you edit them. Clicking the "Apply for a Loan" button saves the values you entered to the deployed copy of the config file, sends the loan application request to the BPEL process, and displays the response.
The bpel_example_config.xml File
This file contains values used by the test client, the two auxiliary Web services, and the Web services test client.
To deploy the config file manually, type
ant deploy-config
The file is then deployed.
BPEL process expected response
In order to properly set the value /rundata/bpel-expected-response located in the config file, you have to understand the example loan approval BPEL process. Here it is, in pseudo-code:
if (amount < 10000) { if (assessor returns "low") return "yes" else return approver response } else return approver response
If either Web service encounters an error, it throws a loanProcessFault exception. If you tell the Web service (via the config file or JSP page) to throw a fault, it will throw a loanProcessFault with a known value. The JSP page and command line clients look for that known value.
Config file changes
Instances of RuntimeParams are responsible for reading the config file. They do so in the constructor. This means that each time a RuntimeParams object is created the config file is re-parsed. Config file changes are picked up immediately. For example, the Web services create a RuntimeParams object each time they are called. That means you can change the config file and deploy it and the next time a Web service is called it will use the new values.
Copyright © 2005 Active BPEL, LLC. - All Rights Reserved