In this last section we generated the client code manually and developed the client to test the Hello World Web service.In this last section we generated the client code manually and developed the client to test the Hello World Web service.
Axis2 ant wsdl2java Example
In this last section we generated the client code manually and developed the client to test the Hello World Web service. In this section we will learn how to use wsdl2java tool from the ant build script.
If you are working on the project then it's better to use the Ant wsdl2java plugin to quickly generate the client code. While developing the project the WSDL file may change several times due to change/update in the business logic, so you need a mechanism to quickly generate the latest stubs for your project. Ant provides the task to help the developer.
Here you will learn to use wsdl2java tool from the Ant.
Setting up Ant tool
You can download the latest version of ant and install on your computer. In this section we will ne needing the ant tool to work with. If you don't know about ant please read our ant tutorial at http://www.roseindia.net/jboss/10_minutes_guide_to_ant.shtml .
Writing the build.xml file
Now we will see how we can develop the code for ant build. I am assuming that you have installed Axis2 binary at E:\Axis2Tutorial\axis2-1.5.1-bin\axis2-1.5.1 and the url of WSDL file is http://localhost:8080/axis2/services/HelloWorldService?wsdl. You can update the build.xml file to point to the axis2 location directory in your computer.
Here is the code of build.xml file.
To run the wsdl2java from ant go to E:\Axis2Tutorial\Examples\AntWSDL2Java\project and then type ant at dos prompt.
Here is the output of the dos prompt:
[axis2-wsdl2java] Retrieving document at 'http://localhost:8080/axis2/services/HelloWorldService?wsdl'.
[axis2-wsdl2java] log4j:WARN No appenders could be found for logger (org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder).
[axis2-wsdl2java] log4j:WARN Please initialize the log4j system properly.
Total time: 3 seconds
Now you can check the src/services to view the generated files. You can use the generated files to call the Web service.