HomeDocumentation > Sample applications > Web services sample application

In a discussion on interoperability of modern day enterprise applications, Web Services naturally joins the party. Web Service technologies provides J2EE with an opportunity to become truly interoperable with any other system. This is because, Web service technologies are platform-agnostic; in other words, the medium used to communicate is not specific to any combination of programming language, operating system, and hardware.


This article is organized into the following sections :

Overview of Web Services Features in Geronimo


  1. A servlet may act as a Web service.
  2. A session bean may act as a Web service.


Application Overview


The following figure illustrates overview of calculator application :



The service implementation class for the web service is CalculatorServiceServlet. It implements all the methods in the service end point interface. This class will be exposed as a servlet in the web.xml file even though it is not necessary to extend javax.servlet.Servlet class.


Note the dependencies section of the geronimo-web.xml file. Those dependencies are mandatory to deploy web services in your web archive.





jaxrpc-mapping file will map the information with service implementation.






Tools used


Java Web Services Developer Kit




Apache Ant


Back to Top

Configuring, Building and Deploying Sample Application

Download the Calculator application from the following link:

After extracting the zip file, the Calculator directory is created.



This sample uses Apache Geronimo v1.2 libraries, make make sure to use "/" as you directory separator in Windows environment when you are setting the <geronimo_home> directory.


Compile Source Code

Use a command prompt and navigate to the Calculator directory and just give ant compile-web command to build. It will compile the source code into the <calculator_home>/releases/war folder. From these compiled classes we are going to create jaxrpc-mapping and WSDL.

Generate WSDL and jaxrpc-mapping files


If you are not happy with given configuration files in <calculator_home>/config/servlet and want to do some experiments, use the Java WSDP to generate jaxrpc-mapping and WSDL files. Follow these steps to generate those files.

  1. Copy <calculator_home>/config/servlet/config-interface.xml to the <wsdp_home>/jaxrpc/bin.
  2. Create a folder called build under <wsdp_home>/jaxrpc/bin and copy classes folder from <calculator_home>/releases/war/WEB-INF/classes. (that is all the org directory structure)
  3. From command prompt issue the following command in <wsdp_home>/jaxrpc/bin.
  4. The previous step has generated both WSDL and jaxrpc-mapping file in the <wsdp_home>/jaxrpc/bin/build folder. The next step is to edit jaxrpc-mapping.xml file according to our services. Change the service-interface to org.apache.geronimo.samples.calc.CalculatorService.
  5. Now copy the jaxrpc-mapping.xml and CalculatorServiceServlet.wsdl files to the <calculator_home>/config/servlet folder.
  6. Remove the build file from <wsdp_home>/jaxrpc/bin.

Create WAR file

To create WAR file use ant command while you are in the <calculator_home> directory, from command prompt. This will create Calculator.war file under the <calculator_home>/releases folder.



  1. Scroll to Deploy New from the Console Navigation panel.
  2. Load Calculator.war from <calculator_home>/releases folder in to the Archive input box.
  3. Press Install button to deploy application in the server.

Testing of the Sample Application

To test this sample application run the CalculatorClient application from the <calculator_home> directory.


D:\Calculator>ant run-client -Dval1=1 -Dval2=12
Buildfile: build.xml

     [java] Working directory ignored when same JVM is used.
     [java] Sum of 1 and 12 is 13

Total time: 1 second



  • Deploy simple Web service in Geronimo as a servlet.
  • Generate Web service related configuration files from Java WSDP.