Developer Resources’s Weblog

June 9, 2008

Java Soap Client using axis library

Filed under: Examples, Java, Web Services — Tags: , , — developerresources @ 6:55 am

This post is an example Java Soap client call using the apache axis library.

First you need to download axis from ws.apache.org. This library provides tools to convert a wsdl into a Java stub class that you can then use.

Once you’ve extracted the axis directory run the following command on the wsdl that you want to consume.

java -cp axis-1_4/lib/wsdl4j-1.5.1.jar:axis-1_4/lib/saaj.jar:axis-1_4/lib/jaxrpc.jar:axis-1_4/lib/axis.jar:axis-1_4/lib/commons-logging-1.0.4.jar:axis-1_4/lib/commons-discovery-0.2.jar:. org.apache.axis.wsdl.WSDL2Java http://webservices.daehosting.com/services/isbnservice.wso?WSDL

If you have your classpath set up you probably don’t need as much but for simplicity I included all the jars in the axis distribution.

Now you can use the stubs that were generated



import com.daehosting.webservices.ISBN.*;

class client {

  public static void main(String argv[]) throws Exception {

    ISBNServiceSoapType service = new ISBNServiceLocator().getISBNServiceSoap();

    System.out.println(service.isValidISBN13("0000000000000"));

  }

}

For further reading I recommend the following book Java Web Services.

2 Comments »

  1. ‘;’ is the proper separator to use between jar names.

    Comment by Michael — November 24, 2008 @ 10:03 pm

  2. I believe it depends on the platform.

    ‘;’ for Windows
    ‘:’ for unix/linux systems.

    Comment by Chris — November 25, 2008 @ 12:57 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.