Monday, January 22, 2007

Understanding ActiveBPEL Tutorial Test Client



Going through the BPEL construction process worked well but I also wanted to discover how the rest of the tutorial worked. So I dug in and hopefully this breakdown will help you. It helped me! :-)





The loan approval components A-F:

A. index.jsp:

Form with values such:
FirstName: John
LastName: Smith
Amount: 500
Operation:request
URL: http://localhost:8080/active-bpel/services/LoanService
Assessor Response: high,low,FAULT
Approver Response: yes,no, FAULT

Upon Submission:

- A form that submits to itself in which the jsp will make a call to the BPEL process

Step 1: update the values of "loan_approval_config.xml"
(~\Active Endpoints\ActiveBPEL Designer\Server\ActiveBPEL_Tomcat\temp\loan_approval_config.xml)
is updated with the values from the form via the RuntimeParams.java class using xpath notation.

Step 2:
Get the BPEL result via the following call:

This call grabs the newly updated values form the above loan_approval_config.xml
and essentially makes a call to the web service via code like:

BPELTestClient.java

Service service = new Service();
Call call = (Call)service.createCall();
String urlString = rp.getAttr("/rundata/client", "url");
call.setTargetEndpointAddress(new java.net.URL(urlString));
call.setOperationName(rp.getAttr("/rundata/client", "operation"));
call.addParameter("firstName", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("name", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("amount", org.apache.axis.Constants.XSD_INTEGER,
ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);

firstName = rp.getText("/rundata/client/firstName");
lastName = rp.getText("/rundata/client/name");
amount = new BigInteger(rp.getText("/rundata/client/amount"));
result = (String)call.invoke(new Object[] {firstName, lastName, amount});

Note however that the index.jsp updates the values for the Assessor and Approver web services in the loan_approval_config.xml.




B. RuntimeParams.java

Class designed to update the "loan_approval_config.xml" file.
It contains a org.w3c.dom.Document and a java.io.File instance variable so that the xml document can be updated via xpath notation.


C. Constants.java

public interface Constants {
public static final String MAGIC_FAULT_STRING = "FAULT";
public static final String MAGIC_FAULT_ERROR_CODE_STRING = "42";
public static final String UNEXPECTED_ERROR_CODE_STRING = "9999";
}



D. loanProcessFault.java

Special extension of org.apache.axis.AxisFault which is thrown by the 2 Web Services
ApproverWebService.java and the AssessorWebService.java


E. The Web Services

Looking at the 2 web services used in the BPEL:

1. ApproverWebService.java
Simply retrieve a value from the loan_approval_config.xml file
RuntimeParams rp = new RuntimeParams();
response = rp.getText("/rundata/approver/accept");

2. AssessorWebService.java
response = rp.getText("/rundata/assessor/risk-level");


Summary
So basics of this BPEL client is index.jsp which

1. updates a loan_approval_config.xml with form values
2. makes a call the to the BPEL by reading the values from loan_approval_config.xml
3. the two partnerLink webservices(Approver and Assessor) read their values from this xml file
4. the jsp is returned the results from the BPEL call

3 comments:

PeSi from Rostock said...

Thanks alot. I really pondered, what the webservice would be used for in this example. Now this lightens it up for me.

Anonymous said...

Casinos Online tyuueooru
Free Casinos
For this purpose, you may require checking out the lists of good gambling websites that are offered on various sites in the form of ratings, reviews, etc.
[url=http://www.nhgaa.org/]Download Online Casino[/url]
This is why online casino seems to be a common interest of many nowadays.
http://www.nhgaa.org/ - Casino Bonus
For this purpose, you may require checking out the lists of good gambling websites that are offered on various sites in the form of ratings, reviews, etc.

Anonymous said...

Good brief and this fill someone in on helped me alot in my college assignement. Say thank you you seeking your information.