Sometime back I wrote an Axis2 hello world tutorial which started with a simple Java class and used a generated client to invoke the service operation. But here we start with a given wsdl file.
You will need the following :
- Axis2 binary distribution
- Apache Ant (installed)
- JDK (installed)
Generate service
Use WSDL2Java to generate service code as follows :
$ /path/to/axis2-binary-distro/bin/wsdl2java.sh -ss -sd -uw -uri service.wsdl -o service/code/dir/path
Complete Service
This is where you will add the business logic to the generated service.
Locate the file
Host Service
Do
$ antin the service/code/dir/path/ directory. This will generate an .aar file in service/code/dir/path/build/lib/ directory. Drop this file into /path/to/axis2-binary-distro/repository/services directory. And start axis2 server with :
$ /path/to/axis2-binary-distro/bin/axis2server.sh
Make sure service is working by pointing the browser to :
http://localhost:8080/axis2/services/service?wsdl
Generate Client
Now you can use the WSDL2Java tool once again to generate a client for the service.
/path/to/axis2-binary-distro/bin/wsdl2java.sh -uw -uri http://localhost:8080/axis2/services/service?wsdl -o client/dir/
Test
The code generated in the previous step provides a