Home > Documentation > Developing > Tutorials > Developing Web services > Developing JAX-RPC Web services |
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.
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.
Geronimo version 2.1.x, Java 1.5 runtime, and Eclipse Ganymede are used is used in this tutorial but other versions can be used instead (e.g., Geronimo version 2.2, Java 1.6, Eclipse Europa)
Details on installing eclipse are provided in the Development environment section. This tutorial will take you through the following steps:
This completes the configuration of Eclipse for application development.
This completes the development of Web services implementation code.
According to JAX-RPC specification, RPC Endpoint should extend Remote Class.
For JAX-WS services, the WSDL file is automatically created by Geronimo at deploy time. However, there is no such facility for RPC services.
Expand WEB-INF directory and add the following code to web.xml
:
Now we need to create some additional files which will configure and describe the service.
Converter.wsdl
:jaxrpcmapping.xml
:
webservices.xml
:
Let us walk through the files that we created.
Converter.wsdl
- Here we specify the web methods which are exposed and what are the request parameters and return parameters. We also specify other details like targetNamespace, service name, binding, port name, port type.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 Java EE 5 webservices.xml is no longer necessary. This file contains all the necessary components to describe web service and where to find them.Now, we will look into the steps involved in deploying and testing our web service without any clients.
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
The most important change that you need to do in your client is to use javax.xml.rpc.Service
instead of javax.xml.ws.Service
.
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 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.
These classes that are required by JAX-RPC are according to J2EE 1.4 standards (As JAX-RPC theoretically maps to J2EE 1.4).
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:
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2013, The Apache Software Foundation, Licensed under ASL 2.0. |