Consuming a Web Service in Java

In order for a Java program to communicate with a Web Service, the Web Services Description Language (WSDL) file must first be consumed. This means that the consumption process would read the WSDL file and create all the necessary classes and code to be used within the Java development environment. There are tools available which perform this consumption process. A commonly used tool is Apache Axis.

You can download this from www.apache.org or use the version of Axis that is installed with ReportCaster.

Perform the following steps to consume a Web Service using Apache Axis:

  1. Modify the following .BAT file:
    SET WF=C:\ibi\WebFOCUS77\webapps\webfocus\WEB-INF\lib\
    SET AXISJARS=%WF%axis.jar
    SET AXISJARS=%AXISJARS%;%WF%axis-ant.jar
    SET AXISJARS=%AXISJARS%;%WF%commons-discovery.jar
    SET AXISJARS=%AXISJARS%;%WF%commons-logging.jar
    SET AXISJARS=%AXISJARS%;%WF%jaxrpc.jar
    SET AXISJARS=%AXISJARS%;%WF%log4j-1.2.14.jar
    SET AXISJARS=%AXISJARS%;%WF%saaj.jar
    SET AXISJARS=%AXISJARS%;%WF%wsdl4j-1.5.1.jar
    SET AXISJARS=%AXISJARS%;%WF%activation.jar
    SET AXISJARS=%AXISJARS%;%WF%mail.jar
    java -classpath %AXISJARS%; org.apache.axis.wsdl.WSDL2Java -v -s -p SStub
    SService.wsdl
  2. Run the .BAT file:

    A sub-directory with a name identified by the package name in the .BAT file is created. In the above example, a sub-directory called SStub will be created containing the Java code to call the Web Service functions.


WebFOCUS