Apache SOAP

A quick guide to using Apache SOAP, based on:

1 Basic Steps

  1. Install Tomcat.
  2. Install Apache Soap.
  3. Write your Java service as a class whose methods you want to export.
  4. Deploy this class as a service.
  5. Write client and use it to access the service.

2 Installing Tomcat

bash

unzip jakarta-tomcat-4.0.1.zip

cd jakarta-tomcat-4.0.1/bin

chmod oug+x *.sh

export JAVA_HOME=/usr/java

export CATALINA_HOME=~/jakarta-tomcat-4.0.1

./startup.sh (runs in background)

lynx http://localhost:8080 (shows the start page)

2.1 Installing SOAP

tar xf soap-bin-2.2.tar

cp soap-2_2/webapps/soap.war jakarta-tomcat-4.0.1/webapps/

3 Writing SOAP Services

package soaptest;
public class CalcService {
  public int add(int p1, int p2) {
  
    return p1 + p2;
  }

  public int subtract(int p1, int p2) {

    return p1 - p2;
  }
}

4 Deploying Service

<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
  id="urn:onjavaserver">
  <isd:provider type="java"
    scope="Application"
    methods="add subtract">
    <isd:java class="onjava.CalcService"/>
  </isd:provider>
  <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
</isd:service>

URLs

  1. Using SOAP with Tomcat, http://www.onjava.com/lpt/a//onjava/2002/02/27/tomcat.html
  2. Apache SOAP User's Guide, http://xml.apache.org/soap/docs/index.html

This talk available at http://jmvidal.cse.sc.edu/talks/apachesoap/
Copyright © 2009 José M. Vidal . All rights reserved.

14 April 2002, 10:23PM