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-RPC compliant web services in Apache Geronimo using Eclipse development environment.

We also wont be focusing very much on developing client for JAX-RPC services as the client stubs generated are very close to that of JAX-WS.

...

If you are new to Web Services, it is strongly recommended that you use JAX-WS 2.0 instead of JAX-RPC. JAX-WS 2.0 comes with many new features not supported by JAX-RPC.

Theoretically JAX-RPC maps to J2EE 1.4 whereas JAX-WS maps to

...

Java EE 5. So JAX-WS leverages the full potential of annotations and other new features which simplifies the application development a lot.

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

...

If you are looking for how to migrate from JAX-RPC to JAX-WS, refer the following tutorial Migrating from JAX-RPC to JAX-WS.

The above tutorial does not go into details on why these changes are required and the concepts behind it, it is rather a quick note that helps you to deal with migrating your application from the older web service stack to new stack.

...

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

  • Sun Sun JDK 5.0+ (J2SE 1.5)
  • Eclipse 3.3.1.1 (Eclipse Classic package of Europa distribution), which is platform specific
  • Web Tools Platform (WTP) 2.0.1
  • Data Tools Platform (DTP) 1.5.1
  • Eclipse Modeling Framework (EMF) 2.3.1
  • Graphical Editing Framework (GEF) 3.3.1

...

titleMigrating from JAX-RPC to JAX-WS

...

  • ) 3.3.1

Details on installing eclipse are provided in the Development environment section. This tutorial will take you through the following steps:

...

...

Setting Up Eclipse for Application Development

...

  1. Right click on JavaRsources:src and select New->Package





  2. Name the package to org.apache.geronimo.samples.jaxrpc and click Finish





  3. Right click on the new package and select New->Interface





  4. Name the interface as Converter and click Finish





  5. Add the following code to the Converter class Code BlocktitleConverter.javaborderStylesolid package org.apache.geronimo.samples.jaxrpc; import java.math.BigDecimal; import java.rmi.Remote; import java.rmi.RemoteException; public interface Converter extends Remote{ public BigDecimal dollarToRupees(BigDecimal dollars) throws RemoteException; public BigDecimal rupeesToEuro(BigDecimal rupees) throws RemoteException; }
  1. Right click on the new package and select New->Class





  2. Name the class as ConverterImpl and click Finish





  3. Add the following code to the ConverterImpl class Code BlocktitleConverterImpl.javaborderStylesolid package org.apache.geronimo.samples.jaxrpc; import java.math.BigDecimal; import java.rmi.RemoteException; public class ConverterImpl implements Converter{ private BigDecimal rupeeRate = new BigDecimal("40.58"); private BigDecimal euroRate = new BigDecimal("0.018368"); public BigDecimal dollarToRupees(BigDecimal dollars) throws RemoteException { BigDecimal result = dollars.multiply(rupeeRate); return result.setScale(2, BigDecimal.ROUND_UP); } public BigDecimal rupeesToEuro(BigDecimal rupees) throws RemoteException { BigDecimal result = rupees.multiply(euroRate); return result.setScale(2, BigDecimal.ROUND_UP); } }

This completes the development of Web Services implementation code.

...

.

...

According to JAX-RPC specification, RPC Endpoint should extend Remote Class.

...

Setting Up the Deployment Descriptor and Deployment Plan

...

As for JAX-WS services, WSDL file is automatically created by Geronimo at deploy time. There is no such facility for RPC services.

...

  • Expand WEB-INF directory and add the following code to web.xml Code Blocktitleweb.xmlborderStylesolid <?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>jaxrpc-converter</display-name> <servlet> <display-name>JAX-RPC Converter Service</display-name> <servlet-name>JAXRPCConverterService</servlet-name> <servlet-class> org.apache.geronimo.samples.jaxrpc.ConverterImpl </servlet-class> </servlet> <servlet-mapping> <servlet-name>JAXRPCConverterService</servlet-name> <url-pattern>/converter</url-pattern> </servlet-mapping> </web-app>
  • Now we need to create some additional files which will configure and describe the service
  • Creating the WSDL file
    • Right click the WEB-INF directory and select New->Other





    • Select WSDL from the Web Services category in the popup box.





    • Name the file as Converter.wsdl and click Finish.





    • Add the following code to Converter.wsdl

...

  • Creating the jaxrpcmapping.xml
    • Right click the WEB-INF directory and select New->Other





    • Select XML from the XML category in the popup box.





    • Name the file as jaxrpcmapping.xml and click Finish.





    • Add the following code to jaxrpcmapping.xml

...

...

  • Creating the webservices.xml
    • Right click the WEB-INF directory and select New->Other





    • Select XML from the XML category in the popup box.





    • Name the file as webservices.xml and click Finish.





    • Add the following code to webservices.xml

...

This completes the setting up of Deployment Descriptor and Deployment Plans.

...

  • jaxrpcmapping.xml - Actually this file specifies the mapping between the java methods and WSDL messages. Here it is not required as we are mapping all the methods to WSDL. For Further reference here is a sample that how a method will be mapped from Java to WSDL.

...

...

  • webservices.xml - This is the file necessary for deploying any web services (JAX-RPC or JAX-WS). But starting from JavaEE5 webservices.xml is no longer necessary.
    This file contains all the necessary components to describe web service and where to find them.

...

  1. Once the application is deployed on to the server, Launch a browser and go to the following url.
    http://localhost:8080/jaxrpc-converter/converter
  2. Now you should see the screen telling that this is Converter Web Service



    Infotitle

    WSDL File

    You can also view the WSDL file generated by Geronimo based on the annotations specified by going to the following url
    http://localhost:8080/jaxrpc-converter/converter?wsdl

...

...

You can also use Web Services Explorer present in Eclipse to rapidly test your web service without developing a client.
To know how to use Web Services Explorer in Eclipse, one can refer to the Developing a JAX-WS POJO Web Service#Using Web Services Explorer in Eclipse

...

Changes required in Client

...

Client development is excluded from this tutorial because there is no big difference in creating a client for JAX-RPC Web Service and a JAX-WS Web Service.

You can refer to Developing a JAX-WS POJO Web Service tutorial for further knowledge about how to develop a client for Web Services.

...

The change you are required to do in the client jsp's are:

...

...

EJB JAX-RPC Web Service

EJB JAX-RPC are very much similiar to POJO JAX-RPC we just implemented. Also the most important change between JAX-RPC and JAX-WS EJB Web service are the EJB anotations are not supported.

  • The class files that are necessary for a EJB JAX-RPC Web Service are:
    • Service Endpoint Interface - Converter.java
    • Home Interface - ConverterHome.java
    • Remote Interface - ConverterRemote.java
    • Bean Implementation - ConverterBean.java

...

...

These classes that are required by JAX-RPC are according to J2EE 1.4 standards (As JAX-RPC theoretically maps to J2EE 1.4).

...

  • Also in ejb-jar.xml, one has to specify which class are you using as Home, Remote, SEI, Bean. A sample ejb-jar.xml may look like this:

...

...

This completes the development of JAX-RPC Web Services. After completing this tutorial you should have a understanding about how JAX-RPC Web Services are deployed.

...

titleJAX-RPC Web Services

...

This completes the development of JAX-RPC Web Services. After completing this tutorial you should have a understanding about how JAX-RPC Web Services are deployed.

...