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
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
public CreateLoanResponse createLoan(CreateLoan cl)
public ProcessLoanPaymentResponse processLoanPayment(ProcessLoanPayment plp)
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.
Build and Deployment of the Loan Payment Processing Web Service
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:
Building the GT4 Deployable GAR File
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):
- Generate bindings for the WSDL.
- Generate stubs from the WSDL. During the setup, it is important to provide a property file that maps the different namespaces to the packages that correspond to our directory structure in the table.
- Compile the stubs.
- Compile the implementation classes.
- Jar the implementation classes, as well as the stub classes (loan.jar and loan_stubs.jar).
- Create the deployable GAR file loan.gar by bundling the deployment descriptor deploy-server.wsdd.
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:
ClassName: Refers to the class that implements the service interface (
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.
Deploying the GAR File
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:
to copy the archive files (loan.wsdl, compiled stubs, compiled implementation, loan.wsdd) into the appropriate server location directory tree of the GT4 container.