Creating A Java Web Service
Creating A Java Web Service
by Haris A.L
1. Introduction
This document explains the steps to create a java web service newly introduced Axis2 Web
Services tools in the Web Tools Platform Project using the latest WTP drivers.
2. Set Up
Tools:
a. IDE – Eclipse Europa Link
b. Web Tools Platform - Link
c. Axis 2 - Link
d. XStream - Link
e. Apache Tomcat Link
In order to create or consume Axis2 Web service components in an Eclipse workspace, the Web
service development tools need to have access to the Axis2 jars to copy them to the Web project
containing the Web service component. Currently, the latest Axis2 version available is Axis2 1.3. If
WTP includes a copy of the Axis2 jars in a plugin, similar to the current implementation of the
tools for Axis 1.3, WTP will need to keep updating the plugin with newer releases of Axis2 as they
become available. Similarly, to the relationship between Server Tools and Apache Tomcat, the
preferred approach is for the user to download the version of Axis2 they want and then point the
Axis2 Web service tools to the location of the download (in zip or unzipped form).
1. In the Preference page, select Web Services -> Axis2 -> Installed Web service runtimes.
2. Expand the Axis2 tree and select Axis2 1.1.
3. Click the Browse button to specify the location of the Axis2 zip or home directory.
4. If the expected Axis2 jars are not found under the specified location, an error message is
shown.
5. Click Finish.
3.1.b Runtime
The above approach is similar to installing a server runtime for Apache Tomcat. The various Axis2
versions are hard-coded (e.g. Axis2 1.0, 1.1, 1.2, etc.) if the various JARs that are needed to run
Axis2 1.x Web service stays the same, it could be just presented as Axis2 1.x. However, if down
the road when there are more Axis2 versions available and the JARs are different, the Web
service runtime adapter for Axis2 would have to be updated to include the newer Axis2 versions
explicitely.
3.2 Next, we need to create a project with the support of Axis2 features. Open File -> New ->
Other... -> Web -> Dynamic Web Project
3.3 Select the name IndustryWS as the Dynamic Web project name (you can specify any name
you prefer), and select the configured Tomcat runtime as the target runtime.
3.7 This page is the service.xml selection page. if you have a custom services.xml, you can
include that by clicking the Browse button. For the moment, just leave it at the default.
3.8 Click next to start the server
3.9 After the server gets started we can click Finish to close the wizard.
If the development environment hosts the web service in localhost we can access the list of
webservices using the url -http://localhost:8080/[PrjName]/services/listServices
The service module can be exported as a war file and hosted in the Tomcat server.
Thus, XStream will provide an easy way to provide a data-binding framework for java objects.