Constructing Web Services with the Globus Toolkit Version 4
Pages: 1, 2, 3, 4, 5
Testing the Loan Payment Processing Example
Client Implementation
Figure 1 described how the loan origination subsystem and the loan accounting subsystem can act as clients to the loan payment processing web services. Now that we have build and deploy our web service in the GT4 grid container, we need to test the services with a client program. Test cases simulate a loan creation event, a loan monthly payment activity event, and a loan pay-off event. The client expects the service URI as one of its arguments from the command line. The client program is compiled separately. Following are a description of the main steps to implement the client to call our web services:
-
Create an
EndpointReferenceTypeobject representing the endpoint reference of the loan service. Our endpoint reference only needs the service's URI.EndpointReferenceType endpoint = new EndpointReferenceType();
endpoint.setAddress(new Address(serviceURI)); -
Next, we obtain a reference to the service's
portType. This is done with a stub class calledLoanServiceAddressingLocator, which takes care of contacting the service (given its endpoint) and getting a reference to the loanportType.LoanServiceAddressingLocator locator = new LoanServiceAddressingLocator();
LoanPortType loanPT = locator.getLoanPortTypePort(endpoint); -
Once we have that reference, we can work with the web service as if it were a local object. For example, to invoke the remote create operation, we simply have to use the
createmethod in theLoanPortTypeobject.CreateLoanResponse clr = loanPT.createLoan(new CreateLoan(amount, loanNumber));
Please see the full code listing in the attached source code for the client. Before compiling the client, make sure you run the following script that comes with the GT4 distribution:
%GLOBUS_LOCATION%/etc/globus-devel-env.bat
The globus-devel-env.bat script takes care of putting all of the Globus libraries into the CLASSPATH, because the client is being compiled as a standalone application. Also, make sure that the CLASSPATH used to compile the client contains the directory where all of the compiled stub classes are placed, so our client can access generated stub classes such as LoanServiceAddressingLocator.
Starting the Grid Container
Use the following GT4 command to start the grid container:
%GLOBUS_LOCATION%/bin/globus-start-container -nosec
The -nosec option disable the security configuration to simplify testing. If the container is started successfully, you'll see a list with the URIs of all the deployed services. If our LoanService is correctly deployed, the following line appears in the list of deployed services (assuming a default GT4 installation):
[13]: http://localhost:8080/wsrf/services/loan/impl/LoanService
Testing the Loan Payment Processing Web Services
To test the service using the client, we consider the following scenarios: creating a loan, making payments, and paying off the loan.
- Create an initial loan with loan number 100 and a UPB (Unpaid Principal Balance) of $120,000:
java Client http://172.24.15.29:8080/wsrf/services/loan/impl/LoanService createLoan 100 120000
Loan 100 created successfully. - Assume two monthly payments of $1,100. (No interest calculations are considered in this example for the sake of simplicity and clarity.)
java Client http://172.24.15.29:8080/wsrf/services/loan/impl/LoanService processLoanPayment 100 1100
Loan 100 processed successfully.java Client http://172.24.15.29:8080/wsrf/services/loan/impl/LoanService processLoanPayment 100 1100
Loan 100 processed successfully. - View the status of the loan:
java Client http://172.24.15.29:8080/wsrf/services/loan/impl/LoanService getLoanData 100
Loan Data
Create Date Mon Jun 06 16:41:06 EDT 2005
Unpaid Principal Balance 117800.0
Status ACTIVE - Pay off the remainder of the loan ($117,800) on the third month:
java Client http://172.24.15.29:8080/wsrf/services/loan/impl/LoanService processLoanPayment 100 117800
Loan 100 processed successfully. - View the status of the loan:
java Client http://172.24.15.29:8080/wsrf/services/loan/impl/LoanService getLoanData 100
Loan Data
Create Date Mon Jun 06 16:41:06 EDT 2005
Unpaid Principal Balance 0.0
Status PAIDOFF
Conclusion
This article described how the GT4 grid infrastructure can be leveraged to create application grid services based on existing web services standards. Although GT4 has been primarily used to solve large scientific computational problems, it can be used as a way to implement a service-oriented architecture within an enterprise. This article shows through a simple example how to create and deploy a grid service using the GT4 Core Java Services. It does not cover the more advanced concepts on how to use other grid services, such as the Grid Resource Allocation and Management (GRAM), Reliable File Transfer (RFT), notification, or security.
Resources
- Sample code for this article
- "Anatomy of the Grid," by Ian Foster, Carl Kesselman, and Steven Tuecke (PDF)
- "The Physiology of the Grid," by Ian Foster, Carl Kesselman, Jeffrey M. Nick, and Steven Tuecke (PDF)
- Globus toolkit
- Java Programmer's Guide Core Framework, Globus GT4.2 Documentation (included in GT4 toolkit)
- Open Grid Services Infrastructure (OGSI) Version 1.0 (PDF)
- Apache AXIS
- Web Services Description Language (WSDL) 1.1, W3C
Birali Hakizumwami is currently working as an application architect.
Return to ONJava.com.
-
Great article
2009-04-07 05:13:22 Welington Veiga [View]
-
Greate article
2009-04-07 05:13:16 Welington Veiga [View]
-
Missing files from sample code
2006-10-20 12:26:18 regimix [View]
- Trackback from http://www.f1fe.com/blog/archives/000338.html
links for 2005-10-21
2005-10-21 16:25:50 [View]