Java Apache Axis2 web services client examples advanced
-
- UpdatedAug 1, 2024
- 3 minutes to read
- Xanadu
- API implementation
Examples showing how to construct and use an Axis2 client to consume a ServiceNow Web Service.
Axis is essentially a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, or gateways. The current version of Axis is written in Java. This content is intended for system admins with a light development background in Java. To begin you would need Java JDK version 1.4.2 or higher and Axis2 version 1.0 or higher.
Create a Java Project
- Open Eclipse and from the menu select .
- Give the project a name.
- Verify that the correct JRE is specified.
- If using wsdl2java run "java -version" on the command line and this will be the version to specify for the project specific JRE.
- If using the Axis2 Codegen plugin use default JRE.
Figure 1. Java Project
Generate your Axis2 client code
- From a command line in the bin directory of the axis folder:
- In the above example:
- The "-uri" is either the path where you have saved a copy of the wsdl to either ".wsdl" or ".xml", or the URL the WSDL resides at.
- The "-o" is the path where you want the files to be written out to. If not specified, the files will be written out to the current bin location.
- In Eclipse refresh the project and the generated Stub and CallbackHandler should now be
displayed
Figure 2. Axis Stub
Basic Authentication
Compatibility with Axis2 Versions 1.1 and higher
- Deployment time: One can disable HTTP chunking by removing or commenting out the following element from Axis2.xml
- Runtime: User can disable the chunking using following property set in Client or Stub, versions 1.1.1 and higher only