Java SOAP Example

Java SOAP Example

Overview

The Axis Library included with screen-scraper makes creating a SOAP client quite easy. Using the WSDL file created from the remote procedures on the screen-scraper server, Axis can create the stubs to make calling the methods in SOAP a matter of just using an object.

The first step in the process is getting screen-scraper running as a server. Please follow that link if you are not familiar with getting screen-scraper running as a server.

The next step is to call the WSDL2Java class in the Axis library. To do so there are six jar files which need to be in the class path to run the class. All of these files are included in the lib directory of screen-scraper. These are the jars:

  • axis.jar
  • commons-discovery.jar
  • commons-logging.jar
  • jaxrpc.jar
  • saaj.jar
  • wsdl4j.jar

One will also need to call the correct class org.apache.axis.wsdl.WSDL2Java. We also recommend changing the output package that the created Java files go to to com.screenscraper.soapclient with the --package option.

Here is an example command-line usage of options just specified above from inside the screen-scraper directory on Windows.

This will create a new directory "com" where the command was issued containing the necessary stubs.

Code Example

The following is an example class which uses the generated classes from above to call on the scraping session created in Tutorial 3. Be sure that the newly created files compile with this one and that the above mentioned jars are in your CLASSPATH. Also, make sure that screen-scraper is running as a server when running the Java code like that below.