Link to home
Start Free TrialLog in
Avatar of srikotesh
srikotesh

asked on

Generating webservice client stubs from WSDL using ANT build/Project

Hi Experts,

I want to generate client stub using soap wsdl.
i am using Ant build.
can some help me how to generate clientstub for real time environments using Ant project.

Thanks,
Avatar of mccarl
mccarl
Flag of Australia image

It doesn't seem as if there are many experts with ANT experience reading your question. Just wondering if you have tried anything and it's just not working or if you just want help on where to start?
Avatar of dfke
dfke

Hi,

you should be able to accomplish this with the ANT wsimport task class.

For instance:

wsimport-ant.xml

        <path id="jaxws-classpath">
		<fileset dir="${jaxws.lib.dir}">
			<include name="**/*.jar" />
		</fileset>
	</path>
	
	<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
		<classpath>
			<path refid="jaxws-classpath" />
		</classpath>
	</taskdef>
	
	<property name="wsdl" value="wsdl_product.xml" />
	
	<target name="generate-yourtarget-ws">
		<delete dir="ws-gen-src" />
		<delete dir="ws-gen-bin" />
		<mkdir dir="ws-gen-src"/>
		<mkdir dir="ws-gen-bin"/>
		<wsimport           
			wsdl="wsdls/${wsdl}"      
				destdir="ws-gen-bin"
				sourcedestdir="ws-gen-src"
				verbose="true"
				package="some.package.name">
		</wsimport>
	</target>

Open in new window

Cheers
Avatar of srikotesh

ASKER

Hi dfke,

I have tried with above steps but source code is not generated.

<property name="wsdl" value="wsdl_product.xml" />///wsdl url data i have kept in this file is that correct?
      
      <target name="generate-yourtarget-ws"> //do i need to change this or i can use as it is
Untested, but with a bit of tweaking it should work. I assume you're using axis2 and you have all axis-related jars in the /lib folder.

<project name="AxisWSImplementation" basedir="."
	default="generate.client">

	<property environment="env" />
	<property name="build.dir" value="build" />

	<path id="axis2.classpath">
		<fileset dir="${basedir}/lib">
			<include name="*.jar" />
		</fileset>
	</path>

	<target name="generate.client">
		<taskdef name="wsdl2java"
			classname="org.apache.axis2.tool.ant.AntCodegenTask"
			classpathref="axis2.classpath" />
		<wsdl2java wsdlfilename="${build.dir}/MyService.wsdl"
			output="${build.dir}/resources" />
	</target>

	<target name="clean">
		<delete dir="${build.dir}" />
	</target>
</project>

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.