SLA Company Logo SLA Office Building

SOAP Examples

The example code on this page shows how a Java application can be used to communicate with the SLA webservices. Of course, webservices are language and platform neutral and other development tools besides Java can be used. Due to the complexity of SOAP webservices these tools use a webservices toolkit to simplify the application development: the freely available Axis2/Java toolkit from the Apache Software Foundation (Apache License 2.0). The example code shown implements MTOM (Message Transmission Optimization Mechanism), but both SLA webservices (UploadXML and UploadImage) are also compatible with SwA (SOAP with Attachments).

SOAP UploadXML

This example shows how to upload the batch data as an XML file using the SOAP webservice. It requires Java SDK 1.5, Apache Ant 1.6.5 and the Apache Axis2/Java 1.3 toolkit.

  1. Verify that you have a correct Java SDK and Runtime Environment:
    java -version (the first line of output should say: java version "1.5.0_13")
    javac -version (the first line of output should say: javac 1.5.0_13)
    The exact version number may differ as long as it is at least version 1.5. Ideally the Java Runtime Environment version and the SDK version matches each other.
  2. Verify that you have a correct Apache Ant build tool:
    ant -version (the first line of output should say: Apache Ant version 1.6.5 or a later version)
  3. If you haven't already done so, extract the keys and certificates from the zipfile that you received from the SLA. You will need the Broker*-key.p12 file which will be used as Keystore and the SLAtestCA-cacert.jks file which will be used as Truststore. For test purposes you can place those two files into the same directory from which you will build and run the sample application.
  4. Download the Apache Axis2/Java software version 1.3 (the Standard Binary Distribution is sufficient)
  5. Unpack the downloaded Apache Axis2/Java package: unzip axis2-1.3-bin.zip
    This will create a new subdirectory axis2-1.3
  6. Download the source code for this example: uploadxmlsample.zip
  7. Unpack the downloaded sample source code: unzip uploadxmlsample.zip
    This will create the new subdirectory src as well as the ant buildfile build.xml.
  8. Your directory layout should now be as follows:
    CurrentDirectory/
    CurrentDirectory/axis2-1.3/
    CurrentDirectory/axis2-1.3/lib/
    CurrentDirectory/axis2-1.3/lib/*.jar (many jar files)
    CurrentDirectory/axis2-1.3/... (several other files and subdirectories)
    CurrentDirectory/build.xml
    CurrentDirectory/src/
    CurrentDirectory/src/client/
    CurrentDirectory/src/client/UploadXMLClient.java
  9. Edit the src/client/UploadXMLClient.java source code to reflect the correct location and filenames of the Truststore and Keystore. At the very least you will need to change the name of the Keystore from Broker9999-key.p12 to reflect your SLA Broker Number.
  10. Compile the sample application: ant
    This will generate java classes from the WSDL file (it will be downloaded automatically) and compile them together with the client code in src/client/UploadXMLClient.java
  11. Create a sample SLACAL_BATCH XML file.
  12. Run the sample application to upload the batch data: ant run -Dfile=sample.xml (this assumes you named the file sample.xml)
  13. If everything went fine, you should get a response with the SLA Batch Id.

SOAP UploadImage

This example shows how to upload a single document image file (can be a multipage TIFF or PDF) using the SOAP webservice. It requires Java SDK 1.5, Apache Ant 1.6.5 and the Apache Axis2/Java 1.3 toolkit.

  1. Verify that you have a correct Java SDK and Runtime Environment:
    java -version (the first line of output should say: java version "1.5.0_13")
    javac -version (the first line of output should say: javac 1.5.0_13)
    The exact version number may differ as long as it is at least version 1.5. Ideally the Java Runtime Environment version and the SDK version matches each other.
  2. Verify that you have a correct Apache Ant build tool:
    ant -version (the first line of output should say: Apache Ant version 1.6.5 or a later version)
  3. If you haven't already done so, extract the keys and certificates from the zipfile that you received from the SLA. You will need the Broker*-key.p12 file which will be used as Keystore and the SLAtestCA-cacert.jks file which will be used as Truststore. For test purposes you can place those two files into the same directory from which you will build and run the sample application.
  4. Download the Apache Axis2/Java software version 1.3 (the Standard Binary Distribution is sufficient)
  5. Unpack the downloaded Apache Axis2/Java package: unzip axis2-1.3-bin.zip
    This will create a new subdirectory axis2-1.3
  6. Download the source code for this example: uploadimagesample.zip
  7. Unpack the downloaded sample source code: unzip uploadxmlsample.zip
    This will create the new subdirectory src as well as the ant buildfile build.xml.
  8. Your directory layout should now be as follows:
    CurrentDirectory/
    CurrentDirectory/axis2-1.3/
    CurrentDirectory/axis2-1.3/lib/
    CurrentDirectory/axis2-1.3/lib/*.jar (many jar files)
    CurrentDirectory/axis2-1.3/... (several other files and subdirectories)
    CurrentDirectory/build.xml
    CurrentDirectory/src/
    CurrentDirectory/src/client/
    CurrentDirectory/src/client/UploadImageClient.java
  9. Edit the src/client/UploadImageClient.java source code to reflect the correct location and filenames of the Truststore and Keystore. At the very least you will need to change the name of the Keystore from Broker9999-key.p12 to reflect your SLA Broker Number.
  10. Compile the sample application: ant
    This will generate java classes from the WSDL file (it will be downloaded automatically) and compile them together with the client code in src/client/UploadImageClient.java
  11. Create (or copy) a sample document image file (TIFF,PDF,PNG,...).
  12. Run the sample application to upload the batch data: ant run -Dfile=sample.tif (this assumes you named the file sample.tif)
  13. If everything went fine, you should get a response that the upload was successful.