Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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.

...

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

  • Bottom Up Web Service - creating web services from Java classes.
  • Top Down Web Service - creating web services from WSDL document.

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.

...

This tutorial will take you through the following steps:

...

...

Create a Dynamic Web Project to host the Web Service

...

  • In Project Explorer view, expand jaxws-converter project, right click on Java Resources: src and select New->Package

  • Specify org.apache.geronimo.samples.jaxws as the package name and click Finish

  • Right click on the new package and select New->Interface
  • Name the interface as Converter and click Finish

  • Add the following code to the Converter interface Code BlocktitleConverter.javaborderStylesolid package org.apache.geronimo.samples.jaxws; import java.math.BigDecimal; import javax.jws.WebService; @WebService(name="ConverterPortType", targetNamespace = "http://jaxws.samples.geronimo.apache.org") public interface Converter { public BigDecimal dollarToRupees(BigDecimal dollars); public BigDecimal rupeesToEuro(BigDecimal rupees); }

  • In Project Explorer view, right click on the new package and select New->Class

  • Name the class as ConverterService, add org.apache.geronimo.samples.jaxws.Converter as Interface and click Finish

  • Add the following code to the ConverterService class Code BlocktitleConverterService.javaborderStylesolid package org.apache.geronimo.samples.jaxws; import java.math.BigDecimal; import javax.jws.WebService; @WebService(serviceName = "Converter", portName = "ConverterPort", endpointInterface = "org.apache.geronimo.samples.jaxws.Converter", targetNamespace = "http://jaxws.samples.geronimo.apache.org") public class ConverterService implements Converter { private BigDecimal rupeeRate = new BigDecimal("40.58"); private BigDecimal euroRate = new BigDecimal("0.018368"); public BigDecimal dollarToRupees(BigDecimal dollars) { BigDecimal result = dollars.multiply(rupeeRate); return result.setScale(2, BigDecimal.ROUND_UP); } public BigDecimal rupeesToEuro(BigDecimal rupees) { BigDecimal result = rupees.multiply(euroRate); return result.setScale(2, BigDecimal.ROUND_UP); } }

Let us try to understand each annotation:

...

  • In Project Explorer view, double click on jaxws-converter->WebContent->WEB-INF->web.xml to open it in an editor and add the following <servlet> and <servlet-mapping> elements inside it.

...

Deploy the Web Service

  • In Servers view, right click on Apache Geronimo Server Runtime and select Add and Remove Projects

  • In the popup dialog, select jaxws-converter project, click Add, and then click Finish
    The Web Service will now be deployed, and Geronimo will create the required .wsdl and other required artifacts.

  • Once the Web Service is deployed on to the server (Server Status says Synchronized), launch a browser and go to the following url:
    http://localhost:8080/jaxws-converter/converter
    You should see a message from Axis2 engine as below:



  • You can also view the WSDL file generated by Geronimo by going to the following url:
    http://localhost:8080/jaxws-converter/converter?wsdl

...

...

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.

...

...

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

...