Axis2 supports several ways to support Web services clients. The most common approach is documented here and involves generating Java code that parses the SOAP message described in the WSDL file.
The following answer describes several ways to invoke a web service. The last part describes a groovy script that uses the classes generated by Axis2 and compiled using ANT:
- Steps to Create a Web Service Using Axis2 - Client Code
More details
The wsdl2java program (bundled with Axis2) will generate an ANT project based on the specified WSDL file:
$AXIS2_HOME/bin/wsdl2java.sh -d adb -s -o mydir -uri http:
This will create the following files:
βββ mydir βββ build.xml βββ src βββ com βββ xmlme βββ webservices βββ ShakespeareStub.java
If you check the generated Java code, you will find java classes that match the types of XML schemas defined in the WSDL file, which will simplify serialization and deserialization of SOAP messages.
The "build.xml" file contains the logic that will compile the generated Java code.
cd mydir ant
When you start the build by default, a jar file will be created as follows:
βββ mydir βββ build β βββ classes β β βββ .. β β .. β βββ lib β βββ Shakespeare-test-client.jar βββ build.xml βββ src βββ com βββ xmlme βββ webservices βββ ShakespeareStub.java
This jar file can now be included in java (or see my groovy script example in another answer ) that wants to access the web service.
Mark o'connor
source share