Differences between revisions 2 and 3
Revision 2 as of 2005-06-26 12:29:36
Size: 8116
Editor: SpyrosBlanas
Revision 3 as of 2009-09-20 22:47:32
Size: 8120
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 162: Line 162:
[http://ws.apache.org/axis Axis] - The SOAP engine [[http://ws.apache.org/axis|Axis]] - The SOAP engine
Line 164: Line 164:
[http://www.netbeans.org/ NetBeans] - The IDE [[http://www.netbeans.org/|NetBeans]] - The IDE

Integrating NetBeans and Axis

Although NetBeans 4.1 ships with web service support, most of the functionality can be only used only in combination with Sun's Application Server.

This tutorial covers these topics:

  1. Installing AXIS in the bundled Tomcat
  2. Exposing the Web Service
  3. Consuming the Web Service

Any new version of NetBeans (4.0+) will do. The steps below are for version 4.1 of NetBeans and 1.2.1 of Axis.


  1. Having started bundled Tomcat at least once. If not, go to "Runtime" tab, click "Servers" and right click on "Bundled Tomcat" entry, select "Start/Stop Server" and press the "Start" button. Wait a while and when "Stop" button is enabled, press it.
  2. Having downloaded Axis.

Installing Axis

  1. Unpack the Axis package.
  2. Locate the bundled Tomcat installation directory. It is under: ~/.netbeans/<NETBEANS_VERSION>/jakarta-tomcat-<TOMCAT_VERSION>_base/ for Linux, or under %USERPROFILE%\.netbeans\<NETBEANS_VERSION>\jakarta-tomcat-<TOMCAT_VERSION>_base\ for Windows. Linux conventions will be used therefore, process in Windows is similar.

  3. Copy the webapps/axis/ folder of the Axis package, to webapps/axis/ folder of the bundled Tomcat installation.

  4. Start the bundled Tomcat server.
  5. Point your browser to http://localhost:8084/axis/ (if you have manually changed the Tomcat port, modify the URL accordingly).

  6. If a nice welcome screen pops up, click the 'Validate' link.
  7. If the core axis libraries are reported to be present, go back and click the 'Call a local endpoint' link. Otherwise, install any required libraries in webapps/axis/WEB-INF/lib folder of the bundled Tomcat installation before continuing.

  8. If an XML document is returned, everything seems to be working fine.

Exposing the Web Service

  1. Create a new project, using "File > New Project..." menu.

  2. Select the "General" category and a "Java Class Library" project. Click "Next".
  3. Give a name to your new project and a location to store the files and click "Finish".
  4. Select "File > New File..." menu, "Java Class" category, "Java Class" file type.

  5. Name the class EchoService, name the package my.ws and click "Finish".

  6. Add a function, which will be the service endpoint, like:

    public String echo(String msg) {
        return "ECHOING: " + msg;
  1. Create two new files for deployment/undeployment, clicking "File > New File..." menu, "Other" category, "Empty File" type, location is project root (empty field) and name the one deploy.wsdd and the other undeploy.wsdd.

  2. Add to deploy.wsdd:

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
    <service name="EchoService" provider="java:RPC">
        <parameter name="className" value="my.ws.EchoService"/>
        <parameter name="allowedMethods" value="*"/>
  • which specifies that all methods of class EchoService at package my.ws should be deployed under the name EchoService.

  1. Add to undeploy.wsdd:

<undeployment xmlns="http://xml.apache.org/axis/wsdd/"
    <service name="EchoService" />
  • which specifies that service with name EchoService should be undeployed.

  1. Go to the "Files" tab, double click on project name and double click on file 'build.xml'.
  2. Add the following code at the end:

    properties which you can use, check the target you are overriding in the
    nbproject/build-impl.xml file. 


    <!-- change the paths of the .wsdd descriptors to reflect your filesystem structure -->
    <target name="-post-init">
        <!-- defining task which will be used to deploy and undeploy the web service -->
        <path id="axis.classpath">
            <fileset dir="${netbeans.user}/jakarta-tomcat-5.5.7_base/webapps/axis/WEB-INF/lib">
                <include name="**/*.jar" />

        <taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />
    <target name="-post-compile">
        <!-- deploy the web sevice -->
        <axis-admin port="8084" hostname="localhost" 
            failonerror="true" servletpath="/axis/services/AdminService" 
            debug="true" xmlfile="deploy.wsdd" />
        <!-- copy the required files in AXIS -->
        <copy todir="${netbeans.user}/jakarta-tomcat-5.5.7_base/webapps/axis/WEB-INF/classes">
            <fileset dir="${build.classes.dir}"/>
    <!-- no -pre-clean target, unfortunately -->
    <target name="-do-clean">   
        <!-- undeploy the web sevice -->
        <axis-admin port="8084" hostname="localhost" 
            failonerror="true" servletpath="/axis/services/AdminService" 
            debug="true" xmlfile="undeploy.wsdd" />
        <!-- delete all files from AXIS which also exist in build/ folder -->
        <delete includeEmptyDirs="true">
            <fileset dir="${netbeans.user}/jakarta-tomcat-5.5.7_base/webapps/axis/WEB-INF/classes">
                <present targetdir="${build.classes.dir}" />
        <!-- do the normal cleaning of dist/ and build/ directories-->
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}"/>     

    CAUTION: Files in {AXIS-INSTALL}/WEB-INF/classes/ may be deleted by accident, if:
    1. You are messing with the build/ folder and then call "clean" target.
    2. If you are using names that already exist in AXIS (like samples.* package).
  • Now every time you build the project, the web service will be compiled and deployed in the bundled Tomcat. When you clean the project, the web service will be undeployed.

You can check that the service has been deployed by entering http://localhost:8084/axis/services/EchoService?wsdl in your browser's URL. If an XML document is returned, deployment was successful.

Consuming the Web Service

  1. Create a new project, using "File > New Project..." menu.

  2. Select the "General" category and a "Java Application" projet. Click "Next".
  3. Give a name to your new project and a location to store the files. Make sure the option "Create Main Class" is checked and click on "Finish".
  4. Add all the libraries from the lib/ directory of AXIS package to the classpath. This can be done by right-clicking on the project name and selecting "Properties". Then select "Libraries", click "Add JAR/Folder" button and select all the *.jar files in lib/ folder.
  5. Add these imports at the beggining of the main-class:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
  1. Add the following code in main():

         try {
             String endpoint =
             Service  service = new Service();
             Call     call    = (Call) service.createCall();
             String ret = (String) call.invoke( new Object[] { "Hello!" } );
             System.out.println("Sent 'Hello!', got '" + ret + "'");
         } catch (Exception e) {
  1. Make sure bundled Tomcat is started and run the application.
  2. A message should be written saying: Sent 'Hello!', got 'ECHOING: Hello!'

That's it!


Axis - The SOAP engine

NetBeans - The IDE

FrontPage/Axis/IDEIntegration/NetBeansIntegration (last edited 2009-09-20 22:47:32 by localhost)