<project name="sample43" default="build">

  <!-- common properties -->
  <property file="../properties.txt" />

  <!-- properties specific to this service -->
  <property name="service" value="HelloWorldService" />
  <property name="service_package" value="tutorial.sample43" />
  <property name="service_war" value="sample43" />

  <property name="server_classes" value="${output_dir}/WEB-INF/classes" />

  <path id="client.class.path">
    <pathelement path="${client_classes}" />
    <pathelement path="${output_dir}/${service}-client.jar" />
    <pathelement path="${java.class.path}" />
  </path>


  <target name="build" depends="clean,setup,compile.schema,compile.server,
                                webservice.build,
                                deploy,compile.client" />

  <target name="clean" description="delete generated stuff" >
    <delete dir="${output_dir}" />
    <delete dir="${client_classes}" />
  </target>

  <target name="setup" description="create output directories" >
    <mkdir dir="${server_classes}" />
    <mkdir dir="${client_classes}" />
  </target>

  <target name="compile.schema" description="generate types from schema" >
    <autotype 
      schemaFile="World.xsd"
      destDir="${output_dir}/WEB-INF/classes"
      keepGenerated="true"
      packageName="${service_package}">
      <classpath>
        <pathelement location="${output_dir}/WEB-INF/classes" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </autotype>
  </target>

  <target name="compile.server" 
    description="compile classes needed on the server side"  >

    <javac srcdir="." includes="*.java" excludes="client/*"
       destdir="${server_classes}" >
    </javac>
  </target>

  <target name="webservice.build"
    description="create web service descriptor, wsdl file, web service client" >

    <autotype 
      javaComponents="${service_package}.${service}"
      typeMappingFile="${output_dir}/WEB-INF/classes/types.xml" 
      destDir="${output_dir}/WEB-INF/classes" 
      packageName="${service_package}">
      <classpath>
        <pathelement location="${output_dir}/WEB-INF/classes" />
        <pathelement location="${output_dir}/WEB-INF/lib" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </autotype>

   <source2wsdd 
     description="create web service descriptor and wsdl from source file"
     javaSource="${service}.java" 
     ddFile="${output_dir}/WEB-INF/web-services.xml"
     typesInfo="${output_dir}/WEB-INF/classes/types.xml"
     serviceURI="/${service}" 
     wsdlFile="${output_dir}/${service}.wsdl" >
     <classpath>
       <pathelement location="${output_dir}/WEB-INF/classes" />
       <pathelement location="${output_dir}/WEB-INF/lib" />
       <pathelement path="${java.class.path}" />
     </classpath>
   </source2wsdd>

   <clientgen 
     description="create a web service client from the wsdl"
     clientJar="${output_dir}/${service}-client.jar"
     wsdl="${output_dir}/${service}.wsdl"
     packageName="${service_package}.client"
     typePackageName="${service_package}.client"
     usePortNameAsMethodName="true" />
  </target>

  <target name="compile.client" 
      description="compile classes needed on the client side" >

    <javac srcdir="." includes="client/*.java" destdir="${client_classes}" >
      <classpath refid="client.class.path" />
    </javac>
  </target>

  <target name="deploy" description="deploy service by copying war to 
                                     application directory" >

    <jar jarFile="${application_dir}/${service_war}.war" 
       baseDir="${output_dir}" />
  </target>

  <target name="browse" description="browse test page for this service" >

    <exec executable="${browser}" >
      <arg line="${server_url}/${service_war}/${service}" />
    </exec>
  </target>

  <target name="run" description="run client" >

    <java classname="${service_package}.client.Main" fork="true" >
      <classpath refid="client.class.path" />
      <arg line="${server_url}/${service_war}/${service}?WSDL" />
      <jvmarg line="-Dweblogic.webservice.verbose=true" />
    </java>
  </target>

</project>

