Monday, 19 December 2011

wsgen & wsimport @ ant

<project>

  <!-- Define classpath -->

  <property name="glassfish.dir" value="C:\Programme\Java\Glassfish3\glassfish" />
  <property name="glassfish.modules.dir" value="${glassfish.dir}\modules" />

  <path id="glassfish.modules.path">
    <fileset dir="${glassfish.modules.dir}">
      <include name="**/*.jar" />
    </fileset>
  </path>

  <!-- Define tasks -->

  <taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
    <classpath refid="glassfish.modules.path" />
  </taskdef>

  <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
    <classpath refid="glassfish.modules.path" />
  </taskdef>

  <!-- Define targets -->

  <target name="server">
    <wsgen keep="true" verbose="true" xendorsed="true" genwsdl="true" fork="true"
      sei="com.company.jaxwstest.server.JavaToWsdl"
      classpath="build/classes"
      destdir="build/classes"
      resourcedestdir="WebContent/WEB-INF/wsdl"
      sourcedestdir="src"/>
  </target>

  <target name="client">
    <wsimport keep="true" verbose="true" xendorsed="true" fork="true"
      wsdl="http://www.webservicex.net/stockquote.asmx?WSDL"
      destdir="build/classes"
      sourcedestdir="src"
      package="com.company.jaxwstest.client"
      binding="binding.xml"/>
  </target>

</project>