If you use Apache Ant to automate your build process, most of the cases this will be a very useful thing to remember. If you want to to generate a Java code using WSDL file this is the way to do it. To do it you need to have Apache CXF as a dependency. Following ant file will gerate a Java code using a given WSDL file.
<project default="compile-all"> <property name="classes" value="$classes"/> <property name="genCode" value="$genCode"/> <property name="dependencies" value="$dependencies"/> <path id="class.path"> <fileset dir="${dependencies}"> <include name="**"/> </fileset> </path> <target name="init"> <mkdir dir="${classes}"/> <mkdir dir="${genCode}"/> </target> <target name="cxfWSDLToJava" depends ="init "> <echo message="Genarating WSDLToJava"/> <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true"> <arg value="-client"/> <arg value="-d"/> <arg value="${genCode}"/> <arg value="-b"/> <arg value="./async_binding.xml"/> <arg value="./hello_world_async.wsdl"/> <classpath> <path refid="class.path"/> </classpath> </java> </target> <target name="compile-all" depends="cxfWSDLToJava"> <javac debug="on" destdir="${classes}"> <src path="${genCode}"/> <classpath refid="class.path"/> </javac> </target> </project>This task will do WSDL2Java conversion. You need to have a dependencies directory created with the necessary cxf jars. You can find them here, http://cxf.apache.org/download.html Also if you need other dependencies to compile you have to put those jars there.Also for further customization please visit this url http://cxf.apache.org/docs/wsdl-to-java.html
No comments:
Post a Comment