#

AXIS WSDL 4 ANT

Gut, wenn man Beispiele für seltener genutzte Kodeschnippsel zur Hand hat. Dieser hier beschreibt, wie man aus einer WSDL per Axis und Ant Javaklassen generiert.

<project name="mysoapclient" default="dist">
	<property name="classes" value="../WEB-INF/classes"/>
	<property name="src" value="../WEB-INF/src"/>
	<property name="lib" value="../WEB-INF/lib"/>
	<!-- libraries only needed for build process -->
	<property name="lib.build" value="../WEB-INF/lib-build"/>
	<path id="classpath">
	    <fileset dir="${lib}">
	      <include name="**/*.jar" />
	    </fileset>
	    <fileset dir="${lib.build}">
	      <include name="**/*.jar" />
	    </fileset>
	  </path>
	<property name="jar-destination" value="../build/versions" />
	<property name="jar-name" value="my-application" />
 
	<target name="dist">
		<tstamp>
		   <format property="version.timestamp" pattern="yyyyMMdd_HHmmss" />
		</tstamp>
		<jar jarfile="${jar-destination}/${jar-name}-${version.timestamp}.jar">
			<fileset dir="${classes}" includes="**"/>
			<manifest>
				<attribute name="Version" value="${version.timestamp}" />
			</manifest>
		</jar>
	</target>
 
	<target name="wsdl2java">
		<!-- needs: saaj.jar, axis.jar, jaxrpc.jar, commons-discovery.jar, wsdl4j.jar, axis-ant.jar -->
		<taskdef name="wsdl2java" classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask" classpathref="classpath"/>
	</target>
 
	<target name="wsdl-someones" depends="wsdl2java">
		<!-- base target package for generated java classes  -->
		<property name="someones.soap.base" value="de/mypackages/soap/someone"/>
		<!-- I use different packages for several namespaces in the wsdl  -->
		<property name="someones.soap.main" value="${someones.soap.base}/service"/>
		<property name="someones.soap.types" value="${someones.soap.base}/types"/>
		<delete dir="${src}/${someones.soap.main}" />
		<delete dir="${src}/${someones.soap.types}" />
		<wsdl2java
			output="${src}"
			verbose="true"
			url="${src}/${someones.soap.base}/thewsdl.wsdl" 
			serverside="false"
			helpergen="true"
			skeletondeploy="true"
			>
			<!-- same as property someone.soap.main -->
			<mapping namespace="http://www.someone.com/soap" package="de.mypackages.soap.someone.service"/>
			<!-- same as property someone.soap.types -->
			<mapping namespace="http://www.someone.com/soap/types" package="de.mypackages.soap.someone.types"/>
		</wsdl2java>
	</target>
</project>
Tags:, , , ,

Leave a Reply »»

Note: All comments are manually approved to avoid spam. So if your comment doesn't appear immediately, that's ok. Have patience, it can take some days until I have the time to approve my comments.