{scrollbar}

This tutorial will take you through the steps required in developing, deploying and testing a Web Service in Apache Geronimo. After completing this tutorial you should be able to understand how to develop simple JAX-WS compliant web services in Apache Geronimo using Eclipse development environment.

This application has a Java class which contains two functions, one which converts amount in Dollars to Rupees and the other which converts Rupees to Euros. We will expose these two methods as the services provided by our deployed Web Service.

We will also test the deployed web service by using the Web Services Explorer in Eclipse

Types of Web Services

For new users, Web Services can be created in two ways:

This tutorial will help you in creating a Bottom Up Web Service from a Java class which will be exposed as a Servlet to the client applications.

To run this tutorial, as a minimum you will be required to have installed the following prerequisite software.

Details on installing eclipse are provided in the Development environment section.

This tutorial will take you through the following steps:

2listpipe

Create a Dynamic Web Project to host the Web Service

Add the POJO Interface and Class that implements the Web Service

Let us try to understand each annotation:

Expose the Web Service as a Servlet in web.xml

xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>jaxws-converter</display-name> <servlet> <display-name>Converter</display-name> <servlet-name>Converter</servlet-name> <servlet-class> org.apache.geronimo.samples.jaxws.ConverterService </servlet-class> </servlet> <servlet-mapping> <servlet-name>Converter</servlet-name> <url-pattern>/converter</url-pattern> </servlet-mapping> </web-app>

Deploy the Web Service

Generated files by Geronimo

Geronimo processes the annotations in source files and automatically generates the required artifacts to deploy the Web Service.

You can see the Geronimo created files in the directory <INSTALL_DIR>/repository/org/apache/geronimo/samples/jaxws/jaxws-converter/1.0/jaxws-converter-1.0.car/. At this location you can find a new directory which Geronimo created for deploying the web service which contains the WSDL file and other required stubs.

How Geronimo creates the WSDL and other required files?

Geronimo has a built-in plug-in named jaxws-tools which provides tools for generating WSDL and other necessary files used in JAX-WS web services. The plug-in relies on Sun's wsgen and wsimport tools to generate the web services artifacts. Please see wsgen or wsimport documentation for more information.

Test the Web Service using Eclipse Web Services Explorer

This completes the process of deploying the web services in Geronimo and testing them. You can also refer to the following tutorial to develop a actual client for a web service that is deployed already on server Developing Client Applications for a JAX-WS Web Service