alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (WsdlToDotnet.xml)

This example Ant source code file (WsdlToDotnet.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

needed, needed, no, no, vb, vb

The WsdlToDotnet.xml source code

<?xml version="1.0"?>

<project name="wsdl-to-java-jtest" basedir="." default="init">


  <property environment="env"/>
  <property name="build.dir" location="wsdl/build"/>
  <property name="cache.dir" location="${build.dir}/cache"/>
  <property name="src.dir" location="${build.dir}/src"/>
  <property name="classes.dir" location="${build.dir}/classes"/>
  <property name="local.wsdl" 
    location="wsdl/StockQuoteService.wsdl" />
  <property name="out.csc" location="${src.dir}/out.cs"/>
  <property name="out.app" location="${classes.dir}/out.dll"/>
  <property name="out.type" value="module"/>
  <property name="out.vbc" location="${src.dir}/out.vb"/>
  <property name="endpoint"
    value="http://nagoya.apache.org:5049/Axis/StockQuoteService.jws" />
  <property name="endpoint.wsdl" 
    value="http://nagoya.apache.org:5049/Axis/StockQuoteService.jws?wsdl" />
  
  <property name="vb.references" 
    value="System.Web.dll,System.xml.dll,System.dll,System.Web.Services.dll"/>
    
  <target name="init" depends="validate">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${cache.dir}"/>
    <mkdir dir="${src.dir}"/>
    <mkdir dir="${classes.dir}"/>
  </target>
  
  <target name="probe_for_apps" >
   <condition property="wsdl.found">
      <or>
        <available file="wsdl"     filepath="${env.PATH}" />
        <available file="wsdl.exe" filepath="${env.PATH}" />
        <available file="wsdl.exe" filepath="${env.Path}" />
      </or>
    </condition>
   <echo> wsdl.found=${wsdl.found}
   <condition property="csc.found">
      <or>
        <available file="mcs"     filepath="${env.PATH}" />
        <available file="csc"     filepath="${env.PATH}" />
        <available file="csc.exe" filepath="${env.PATH}" />
        <available file="csc.exe" filepath="${env.Path}" />
      </or>
    </condition>
   <echo> csc.found=${csc.found}
   <condition property="vbc.found">
      <or>
        <available file="vbc"     filepath="${env.PATH}" />
        <available file="vbc.exe" filepath="${env.PATH}" />
        <available file="vbc.exe" filepath="${env.Path}" />
      </or>
    </condition>
   <echo> vbc.found=${vbc.found}
   <condition property="dotnetapps.found">
      <and>
        <isset property="csc.found"/>
        <isset property="wsdl.found"/>
      </and>
    </condition>
   <echo> dotnetapps.found=${dotnetapps.found}
  </target>
  
  <target name="teardown">
    <delete dir="${build.dir}"/>
  </target>  

  <target name="validate" depends="probe_for_apps" >
    <fail unless="dotnetapps.found">Needed .net apps are missing
  </target>  
  
  
  <target name="testNoParams">
    <wsdltodotnet/>
  </target>

  <target name="testNoSrc">
    <wsdltodotnet destFile="${out.csc}"/>
  </target>

  <target name="testDestIsDir" depends="init">
    <wsdltodotnet destFile="${build.dir}"
      srcFile="${local.wsdl}"/>
  </target>
  
  <target name="testBothSrc" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      url="${endpoint.wsdl}"
      />
  </target>

  <target name="testSrcIsDir" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${build.dir}"
      />
  </target>

  <target name="testSrcIsMissing" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${build.dir}/invalidfile.wsdl"
      />
  </target>
  
  <target name="testLocalWsdl" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      />
    <csc 
      srcDir="${src.dir}"
      destFile="${out.app}"
      targetType="${out.type}"
      references="System.Web.Services.dll"
      />
    <available property="app.created" file="${out.app}"/>
    <fail unless="app.created">No app created
  </target>
  
  <target name="testLocalWsdlServer" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      server="true"
      />
    <csc 
      srcDir="${src.dir}"
      destFile="${out.app}"
      targetType="${out.type}" 
      fileAlign="512"
      references="System.Web.Services.dll"
      />
    <available property="app.created" file="${out.app}"/>
    <fail unless="app.created">No app created
  </target>
  
  <target name="testInvalidExtraOps" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      extraOptions="/newOption:not-one-known-of"
      />
  </target>


  
  <target name="testLocalWsdlVB" depends="init" if="vbc.found">
    <wsdltodotnet destFile="${out.vbc}"
      language="VB"
      srcFile="${local.wsdl}"
      />
    <vbc 
      srcDir="${src.dir}"
      destFile="${out.app}"
      targetType="${out.type}"
      references="${vb.references}"
      >
      
      </vbc>
    <available property="app.created" file="${out.app}"/>
    <fail unless="app.created">No app created
  </target>
  
  <target name="testLocalWsdlServerVB" 
    depends="init" if="vbc.found">
    <wsdltodotnet destFile="${out.vbc}"
      language="VB"
      srcFile="${local.wsdl}"
      server="true"
      />
    <vbc 
      srcDir="${src.dir}"
      destFile="${out.app}"
      targetType="${out.type}" 
      optionExplicit="true"
      optionStrict="false"
      optionCompare="text"
      references="${vb.references}"
      />
    <available property="app.created" file="${out.app}"/>
    <fail unless="app.created">No app created
  </target>
  
  <target name="testInvalidExtraOpsVB" depends="init">
    <wsdltodotnet destFile="${out.vbc}"
      language="VB"
      srcFile="${local.wsdl}"
      extraOptions="/newOption:not-one-known-of"
      />
  </target>


  <target name="testideErrorsIgnoredWhenFalse" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      ideErrors="false"
      >
    </wsdltodotnet>
  </target>

  <target name="testSchemaMustBeSet" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      >
      <schema/>
    </wsdltodotnet>
  </target>

  <target name="testSchemaFileMustExist" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      >
      <schema file="this-file-does-not-exist.xsd"/>
    </wsdltodotnet>
  </target>

  <target name="testSchemaFileMustHaveOneOptionOnly" depends="init">
    <wsdltodotnet destFile="${out.csc}"
      srcFile="${local.wsdl}"
      >
      <schema file="WsdlToDotnet.xml"
        url="http://ant.apache.org/xml/AntSchema.xsd"/>
    </wsdltodotnet>
  </target>

</project>

Other Ant examples (source code examples)

Here is a short list of links related to this Ant WsdlToDotnet.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.