| Sign In/My Account | View Cart |
Constructing Web Services with the Globus Toolkit Version 4
Pages: 1, 2, 3, 4, 5
In the previous step, the LoanPortType endpoint interface was generated. All remotely available operations must be public and throw java.rmi.RemoteException, as defined in the PortType interface. In this section, we provide a class, LoanServiceImpl, that implements the LoanPortType interface. The implementation uses stub classes that were generated from the loan.wsdl file from the previous section.
public class LoanServiceImpl implements LoanPortType
The LoanServiceImpl class implement the methods defined in the LoanPortType interface. The createLoan method takes a loanNumber as a parameter in the constructor of the generated CreateLoan object.
public CreateLoanResponse createLoan(CreateLoan cl)
throws java.rmi.RemoteException
public ProcessLoanPaymentResponse processLoanPayment(ProcessLoanPayment plp)
throws java.rmi.RemoteException
public GetLoanResponse getLoan(GetLoan gl) throws java.rmi.RemoteException
Please refer to the full source code in the Resources section for the details of the methods' implementations.
To build a deployable GT4 archive file, we follow the steps described below. The build.xml Ant build file provided with this article contains the tasks to perform these steps. The Ant tasks in build.xml call the following GT4 Ant tasks that can be found in the build files that come with the GT4 distribution:
%GLOBUS_LOCATION%/share/globus_wsrf_common/build-packages.xml
%GLOBUS_LOCATION%/share/globus_wsrf_tools/build-stubs.xml
%GLOBUS_LOCATION%/share/schema
To build our deployable grid archive file (GAR), loan.gar, we follow the following steps (these steps correspond to the Ant tasks in build.xml):
Please refer to the full build.xml in the source code for the complete list of Ant build tasks for the above steps. The GT4 deployment descriptor deploy-server.wsdd for our web service will look like this:
<service name="loan/impl/LoanService" provider="Handler"
use="literal" style="document">
<parameter name="className" value="loan.impl.LoanServiceImpl"/>
<wsdlFile>share/schema/loan/Loan_service.wsdl</wsdlFile>
<parameter name="allowedMethods" value="*"/>
<parameter name="handlerClass"
value="org.globus.axis.providers.RPCProvider"/>
<parameter name="scope" value="Application"/>
<parameter name="providers" value="GetRPProvider"/>
<parameter name="loadOnStartup" value="true"/>
</service>
Let's describe some parameters found in the deploy-server.wsdd file:
Service name: Specifies the location where our web service will be found. If we combine this with the base address of our web services container, we will get the full URI of our web service. For testing purposes using the GT4 standalone container, the URL looks like this:
http://localhost:8080/wsrf/services/loan/impl/LoanService
ClassName: Refers to the class that implements the service interface (LoanServiceImpl).
WSDL file: Tells the GT4 web services container where the WSDL file for this service can be found. This WSDL file, Loan_service.wsdl, is generated automatically by a GT4 Ant task from loan.wsdl.
Load on startup: Allows us to control if we want the service to be loaded as soon as the container is started.
The GAR file loan.gar contains all of the files and information the web server needs to deploy the web service. We use the GT4 deployment tool:
%GLOBUS_LOCATION%/bin/globus-deploy-gar $PROJECT_HOME/loan.gar
to copy the archive files (loan.wsdl, compiled stubs, compiled implementation, loan.wsdd) into the appropriate server location directory tree of the GT4 container.