January 25, 2021
Hot Topics:

Developing JAX-RPC-Based Web Services Using Axis and SOAP

  • By Rajesh Sumra
  • Send Email »
  • More Articles »

Sample Web Service: Order Processing Web Service

I have chosen an 'order processing' example for its proximity to real business use case. This Web service will be capable of processing and updating a given order. For this, it will have two methods: processOrder and updateOrder. processOrder will be taking an orderID string as an IN parameter and an Order object as an OUT parameter. It will return a status string as a return parameter. updateOrder will be taking the Order object as an INOUT parameter and it will update orderDate and return the Order object back to the client. As both of these methods are using a complex datatype, Order, that is also an OUT/INOUT parameter, a holder class has to be developed. The Order class and its holder class are given below in Listings 1 and 2 (For clarity, the whole code is in the sample package):

Listing 1: Class Order.

package sample;
public class Order {
  // ID for order
  private String orderID = null;

  // date of order
  private String orderDate= null;

  // getter methodspublic String getOrderID() {
            return orderID;
 public String getOrderID() {
        return orderID;
  // setter methods
  public void setOrderID(String orderID) {
              this.orderID = orderID;
  } public void setOrderDate(String orderDate) {
                this. orderDate = orderDate;

Listing 2: Holder class for Class Order.

// Note that holder class is in the holders package and its name
// is derived by adding Holder as a suffix to 'Order', as per
// the JAX-RPC specification.
package sample.holders;

public class OrderHolder {
  // Order's object
  public Order  value = null;

  // default constructor
  public void OrderHolder () { }

  // constructor, which takes value as a parameter
  public void OrderHolder (Order value) {

Now, let's develop our Web service for the described functionality. The code is given in Listing 3.

Listing 3: Order Processing Web service.

package sample;
public class OrderProcessingService {
  // Method 1: processes a order given ID as input and
  // return status and Order object as an OUT parameter
  public String processOrder(String orderID,
                             OrderHolder orderHolder ) {
                             String status = "pending";
    // perform business logic here
    // for simplicity just filling the Order object
    Order order = new Order();
    order.setOrderDate("03 March 2003");

    // set the Holder value to the order.
    orderHolder.value = order;
    //set the status
    status = "complete" ;
    return status;
  // Method 2: updates a order given Order as an INOUT
  // parameter and returns status.
  public String updateOrder(OrderHolder orderHolder) {
                            String status = "pending";
    // perform update here
    Order order = orderHolder.value;
    order.setOrderDate("03 April 2003");

    // Note that orderID is not changed.
    // It will be same as the passed one.

    // set the Holder value to the order.
    orderHolder.value = order;
    //set the status
     status = "complete" ;
    return status;

Now that we have finished with Web service development, the next step is to compile and deploy it on a Tomcat-Axis platform. After compilation, we need to deploy the preceding Web service on Tomcat-Axis, using a deployment descriptor. The sample 'deploy.wsdd' is shown in Listing 4 (for more details, please refer to the Tomcat-Axis Manual).

Listing 4: deploy.wsdd for deployment.

<deployment xmlns="http://xml.apache.org/axis/wsdd/"

<service name=" OrderProcessingService" provider="java:RPC">
  <parameter name="className"
             value="sample.OrderProcessingService "/>
  <parameter name="allowedMethods" value="*"/>
    <operation name="processOrder">
      <parameter name="arg1" mode="IN"/>
      <parameter name="arg2" mode="OUT"/>
    <operation name="updateOrder">
      <parameter name="arg1" mode="INOUT"/>

The above deployment descriptor actually tells the server about the Web service, such as methods it exposes, parameters it is expecting, and the return types. To deploy the OrderProcessingService, we need to invoke the Axis admin service, passing this "deploy.wsdd". The admin service, which is also running on the same server, will process the descriptor and deploy the Web service, so that it is ready to be invoked by clients.

Execute the following command from where you have kept the deploy.wsdd:

java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient
-lhttp://localhost:8080/axis/services/AdminService deploy.wsdd

Where AXISCLASSPATH is used to set the environment for Axis (for details, see the axis installation guide).

The OrderProcessing service will be available at the following URL:

In our case, it may look like:

Page 2 of 3

This article was originally published on July 18, 2003

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date