Example 32 : Ant Task to Generate Java Code From WSDL
To avoid problems, we heartily recommend generating client code from WSDLs, rather than doing it by hand. We've also found it useful to generate all the client code into a simple package, and then compile that up into a single JAR.
That way, you need only include a reference to the compiled JAR, and any related references (such as Apache Axis).
This instruction will take the AllocationService WSDL and generate all the necessary code. Normally, you will make use of more than one service. In that case, it is safe to generate the code into the same package structure for each service, as type definitions are shared between the services.
${soap.url} is the URL to the WSDL location. In this case, it's located on a server. If you're generating from WSDLs on your file system, this will need to change. ${soap.user} and ${soap.password} are the credentials to use when accessing the webservices during the code generation only. The account only needs to access the web services, and does not need rights to perform any action. If you are generating code from WSDLs on your file system, neither of these parameters need be provided.
<taskdef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask" classpathref="project.classpath" /> ... <property name="soap.url" value="http://test2.metapack.com/dm/services" /> <property name="soap.user" value="MyCaseSensitiveUserName" /> <property name="soap.password" value="MyCaseSensitivePassword" /> ... <wsdl2java url="${soap.url}/AllocationService?wsdl" debug="true" printstacktraceonfailure="true" username="${soap.user}" password="${soap.password}" output="src"> <mapping namespace="urn:DeliveryManager/types" package="com.metapack.deliverymanager.client" /> <mapping namespace="urn:DeliveryManager/services" package="com.metapack.deliverymanager.client.webservices" /> </wsdl2java>

