axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r351658 - /webservices/axis2/trunk/java/xdocs/CodegenToolReference.html
Date Fri, 02 Dec 2005 10:07:33 GMT
Author: ajith
Date: Fri Dec  2 02:07:28 2005
New Revision: 351658

URL: http://svn.apache.org/viewcvs?rev=351658&view=rev
Log:
Added the document done by trebor Iksrazal as part of the tool reference

Modified:
    webservices/axis2/trunk/java/xdocs/CodegenToolReference.html

Modified: webservices/axis2/trunk/java/xdocs/CodegenToolReference.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/CodegenToolReference.html?rev=351658&r1=351657&r2=351658&view=diff
==============================================================================
--- webservices/axis2/trunk/java/xdocs/CodegenToolReference.html (original)
+++ webservices/axis2/trunk/java/xdocs/CodegenToolReference.html Fri Dec  2 02:07:28 2005
@@ -1,226 +1,702 @@
-<title>Code Generator Wizard - Eclipse Plug-in</title>
-<h1>Code Generator Wizard - Eclipse Plug-in</h1>
-<h2>Introduction</h2>
-<p>The Axis2 code generator comes built-in with an
-<a href="http://www.eclipse.org">Eclipse</a> plug-in. This document explains
the 
-installation and usage of the Axis2 code generator plug-in.</p>
-<h2>Installation</h2>
-<p>The easiest way to obtain the plug-in would be the binary distribution. The 
-full Axis binary distribution contains the compiled version of this plug-in 
-under the tools directory. </p>
-<p>If one needs to build the plugin from source it is not as trivial as running 
-the Maven build. The reason is that the plug-in depends heavily on the Eclipse 
-classes, which are only available in an Eclipse environment. The recommended 
-procedure is to run the create-project.xml (in the "modules\tool" directory of the source
distribution) build file which will create two 
-folders (the other one for the Service Archiver tool) and copy the necessary 
-files to relevant folders. Then Eclipse should be configured to open the 
-contents in a PDE project. Please go through the Eclipse documentation to learn 
-how to open projects in the PDE format.</p>
-<p>Once you've obtained the plug-in just unzip the content of the plug-in 
-archive to the eclipse plug-in directory (if it is the zipped-binary version) or 
-copy the necessary folders to the eclipse plug-in directory and restart Eclipse.</p>
-<p><i>Note - This plug-in works on Eclipse version 3.0 and upwards</i></p>
-<h2>Operation</h2>
-<p>If the plug-in is properly installed you should see a new wizard under the 
-&quot;New&quot; section.(use the File -&gt; New -&gt; Other or Ctrl + N )
</p>
-<p>
-<img border="0" src="images/tools/wsdl/wizardSelectionPage.jpg" width="500" height="500"></p>
-<p>Selecting the wizard and pressing the next button will start the code 
-generator wizard. Following is the first wizard page.</p>
-<p>
-<img border="0" src="images/tools/wsdl/toolSelectionpage.jpg" width="557" height="501"></p>
-<p>Selecting the generate code from WSDL option leads to the next page. Note 
-that the Java-to-WSDL tool is disabled.</p>
-<p>
-<img border="0" src="images/tools/wsdl/WSDLSelectionPage.jpg" width="518" height="500"></p>
-<p>To move on to the next page the WSDL file location must be given. The browse 
-button can be used to easily browse for a file rather than typing the whole 
-path.</p>
-<p>Once the WSDL file is selected, codegen options are to be selected. By far 
-this is the most important page in this wizard, which determines the 
-characteristics of the code being generated. Novices need not worry about these 
-options since the most common options are defaulted, But advanced users will 
-find it very easy to &quot;turn the knobs&quot; using these options.</p>
-<p><img border="0" src="images/tools/wsdl/OptionsPage.jpg" width="518" height="500"></p>
-<p>Once the options are taken care of, only the final step of the code 
-generation is left. it is the selection of the output file location.</p>
-<p><img border="0" src="images/tools/wsdl/OutputPage.jpg" width="518" height="500"></p>
-<p>When the output file location is selected, the Finish button will be enabled. 
-Pressing the finish button will generate the code and a message box will pop up 
-acknowledging the success. Well Done! Now you are ready for Axis2 Code generation.</p>
-<h1>Code Generator Wizard - Command Line Tool</h1>
-<h2>Introduction</h2>
-<p>Just as old times there will be users who wish to use the command line 
-version of the tool. This basic tool is implemented by the WSDL2Code class and 
-just for the convenience in the java case (which would be the majority) there is 
-another WSDL2Java class. One can choose to run the main classes directly or use 
-one of the scripts to run the WSDL2Code and WSDL2Java appropriately. (the 
-scripts are found in the bin directory of the binary distribution)</p>
-<h2>Option Reference</h2>
-<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
width="100%" id="AutoNumber1">
-  <tr>
-    <td width="50%">-uri &lt;Location of WSDL&gt;</td>
-    <td width="50%">WSDL file location. This should point to a WSDL file in the 
-    local file system</td>
-  </tr>
-  <tr>
-    <td width="50%">-o &lt;output Location&gt; : </td>
-    <td width="50%">output file location. This is where the files would be 
-    copied once the code generation is done. If this option is omitted the 
-    generated files would be copied to the working directory. </td>
-  </tr>
-  <tr>
-    <td width="50%">-l &lt;language&gt;</td>
-    <td width="50%">Output language. Currently the code generator can generate 
-    code in Java and CSharp. (CSharp support is limited) When omitted defaults 
-    to Java.<p>Allowed options are</p>
-    <ul>
-      <li>java</li>
-      <li>cs</li>
-    </ul>
-    </td>
-  </tr>
-  <tr>
-    <td width="50%">-p &lt;package name&gt; </td>
-    <td width="50%">The target package name. If omitted, a default package 
-    (formed using the target&nbsp; namespace of the WSDL) will be used.</td>
-  </tr>
-  <tr>
-    <td width="50%">-a</td>
-    <td width="50%">Generate code only for async style . when this option is 
-    used the generated stubs will have only the asynchronous invocation methods. 
-    Switched off by default.</td>
-  </tr>
-  <tr>
-    <td width="50%">-s</td>
-    <td width="50%">Generate code only for sync style . When this option is 
-    used the generated stubs will have only the  synchronous invocation methods. 
-    Switched off by default. When used with the -a option, this takes 
-    precedence.</td>
-  </tr>
-  <tr>
-    <td width="50%">-t</td>
-    <td width="50%">Generates a test case. In the case of Java it would be a 
-    junit test case. This test case will generate a dummy implementation of the service and
a relevant service.xml and will deploy this particular service in a SimpleHttpServer. Then
looking at the WSDL it will generate test methods that will do web service invocation both
synchronously and asynchronously and test the deployed service.</td>
-  </tr>
-  <tr>
-    <td width="50%">-ss</td>
-    <td width="50%">Generates server side code (i.e. skeletons). Default is off</td>
-  </tr>
-  <tr>
-    <td width="50%">-sd</td>
-    <td width="50%">Generates the service descriptor (i.e. server.xml). Default is
off. 
-    only valid with -ss</td>
-  </tr>
-</table>
-<h1>Code Generator Wizard - Ant Task</h1>
-<p>The code generator also comes bundled with an Ant task. The ant task is 
-implemented by the org.apache.axis2.tool.ant.AntCodegenTask class. Following are
-the ant task attributes.</p>
-<h2>Ant Task Reference</h2>
-<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
width="100%" id="AutoNumber2" height="458">
-  <tr>
-    <td width="50%" height="19">wsdlfilename</td>
-    <td width="50%" height="19">WSDL file location. Maps to the uri option of 
-    the command line tool</td>
-  </tr>
-  <tr>
-    <td width="50%" height="76">output</td>
-    <td width="50%" height="76">output file location. This is where the files would
be 
-    copied once the code generation is done. If this option is omitted the 
-    generated files would be copied to the working directory. . Maps to the -o 
-    option of the command line tool</td>
-  </tr>
-  <tr>
-    <td width="50%" height="171">language</td>
-    <td width="50%" height="171">Output language. Currently the code generator can
generate 
-    code in Java and CSharp. (CSharp support is limited) When omitted defaults 
-    to Java.<p>Allowed options are</p>
-    <ul>
-      <li>java</li>
-      <li>cs</li>
-    </ul>
-    <p>Maps to the -l option of the command line tool</td>
-  </tr>
-  <tr>
-    <td width="50%" height="57">packagename</td>
-    <td width="50%" height="57">The target package name. If omitted, a default package

-    (formed using the target&nbsp; namespace of the WSDL) will be used.&nbsp; 
-    Maps to the -p option of the command line tool.</td>
-  </tr>
-  <tr>
-    <td width="50%" height="75">asynconly</td>
-    <td width="50%" height="75">Generate code only for async style . when this option
is 
-    used the generated stubs will have only the asynchronous invocation methods. 
-    Defaults to false if omitted Only true and false are applicable as values. 
-    Maps to the -a option of the command line tool.</td>
-  </tr>
-  <tr>
-    <td width="50%" height="16">testcase</td>
-    <td width="50%" height="16">Generates a test case </td>
-  </tr>
-  <tr>
-    <td width="50%" height="19">synconly</td>
-    <td width="50%" height="19">Generate code only for sync style . when this option
is 
-    used the generated stubs will have only the  synchronous invocation methods. 
-    Defaults to false if omitted. Only true and false are applicable as values. 
-    Maps to the -s option of the command line tool.</td>
-  </tr>
-  <tr>
-    <td width="50%" height="19">serverside</td>
-    <td width="50%" height="19">Generates server side code (i.e. skeletons). 
-    Only true and false are applicable as values. Default is false. Maps to the 
-    -ss option of the command line tool</td>
-  </tr>
-  <tr>
-    <td width="50%" height="18">generateserverxml</td>
-    <td width="50%" height="18">Generates server side code (i.e. skeletons). 
-    Only true and false are applicable as values. Default is false. Maps to the 
-    -sd option of the command line tool.</td>
-  </tr>
-</table>
-<h2>Example build file using the custom Ant task</h2>
-<p>Following is an example ant build file that uses the custom Ant task.</p>
-<p><pre>&lt;?xml version=&quot;1.0&quot;?&gt;
-&lt;project name=&quot;CodegenExample&quot; default=&quot;main&quot;
basedir=&quot;.&quot;&gt;
-&lt;target name=&quot;declare&quot; &gt;
-&lt;taskdef name=&quot;codegen&quot;
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; classname=&quot;org.apache.axis2.tool.ant.AntCodegenTask&quot;
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; classpath=&quot;classes&quot;/&gt;
-&lt;/target&gt;
-&lt;target name=&quot;main&quot; depends=&quot;declare&quot;&gt;
-&lt;codegen 
-&nbsp;&nbsp;&nbsp; wsdlfilename=&quot;C:\test\wsdl\CombinedService.wsdl&quot;
-&nbsp;&nbsp;&nbsp; output=&quot;C:\&quot;
-&nbsp;&nbsp;&nbsp; serverside=&quot;true&quot;
-&nbsp;&nbsp;&nbsp; generateserverxml=&quot;true&quot;
-/&gt;
-&lt;/target&gt;
-&lt;/project&gt;</pre></p>
-<p>Notice the main target that uses the "codegen" task which will use the org.apache.axis2.tool.ant.AntCodegenTask
class and run the code generation tool internally while passing the relevant arguments and
do the proper generation. If a user types</p>
-<p>>ant or >ant main</p>
-<p>it will generate the serverside code and service.xml for the given WSDL file(C:\test\wsdl\CombinedService.wsdl)
and the generated code will be written to C:\ directory.</p>
-<p>For this Ant task to work the following jars need to be in the class path.</p>
-<ul>
-  <li>axis-M2.jar (from the Axis2 distribution)</li>
-  <li>axis-wsdl4j-1.2.jar (The WSDL4J implementation jar. Bundled with the Axis2 
-  distribution)</li>
-  <li>stax-api-1.0.jar (The StAX API's that contain the 
-  javax.xml.namespace.QName class. This jar may be replaced by any other jar 
-  that contains the javax.xml.namespace.QName implementation. However Axis2 uses 
-  this class from the stax-api-1.0.jar which comes bundled with the Axis2 
-  distribution)</li>
-</ul>
-<h1>Appendix</h1>
-<ul>
-  <li>Eclipse reference - <a href="http://www.eclipse.org/">
-  http://www.eclipse.org/</a></li>
-  <li>Custom Ant Tasks&nbsp; -
-  <a href="http://ant.apache.org/manual/develop.html">
-  http://ant.apache.org/manual/develop.html</a></li>
-</ul>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
-<p>&nbsp;</p>
\ No newline at end of file
+<html>
+<head>
+  <meta http-equiv="content-type" content="">
+  <title>Code Generator Wizard - Eclipse Plug-in</title>
+</head>
+
+<body>
+<h1>Code Generator Wizard - Eclipse Plug-in</h1>
+
+<h2>Introduction</h2>
+
+<p>The Axis2 code generator comes built-in with an <a
+href="http://www.eclipse.org">Eclipse</a> plug-in. This document explains the
+installation and usage of the Axis2 code generator plug-in.</p>
+
+<h2>Installation</h2>
+
+<p>The easiest way to obtain the plug-in would be the binary distribution.
+The full Axis binary distribution contains the compiled version of this
+plug-in under the tools directory.</p>
+
+<p>If one needs to build the plugin from source it is not as trivial as
+running the Maven build. The reason is that the plug-in depends heavily on
+the Eclipse classes, which are only available in an Eclipse environment. The
+recommended procedure is to run the create-project.xml (in the "modules\tool"
+directory of the source distribution) build file which will create two
+folders (the other one for the Service Archiver tool) and copy the necessary
+files to relevant folders. Then Eclipse should be configured to open the
+contents in a PDE project. Please go through the Eclipse documentation to
+learn how to open projects in the PDE format.</p>
+
+<p>Once you've obtained the plug-in just unzip the content of the plug-in
+archive to the eclipse plug-in directory (if it is the zipped-binary version)
+or copy the necessary folders to the eclipse plug-in directory and restart
+Eclipse.</p>
+
+<p><i>Note - This plug-in works on Eclipse version 3.0 and upwards</i></p>
+
+<h2>Operation</h2>
+
+<p>If the plug-in is properly installed you should see a new wizard under the
+"New" section.(use the File -&gt; New -&gt; Other or Ctrl + N )</p>
+
+<p><img src="images/tools/wsdl/wizardSelectionPage.jpg" width="500"
+height="500"></p>
+
+<p>Selecting the wizard and pressing the next button will start the code
+generator wizard. Following is the first wizard page.</p>
+
+<p><img border="0" src="images/tools/wsdl/toolSelectionpage.jpg" width="557"
+height="501"></p>
+
+<p>Selecting the generate code from WSDL option leads to the next page. Note
+that the Java-to-WSDL tool is disabled.</p>
+
+<p><img border="0" src="images/tools/wsdl/WSDLSelectionPage.jpg" width="518"
+height="500"></p>
+
+<p>To move on to the next page the WSDL file location must be given. The
+browse button can be used to easily browse for a file rather than typing the
+whole path.</p>
+
+<p>Once the WSDL file is selected, codegen options are to be selected. By far
+this is the most important page in this wizard, which determines the
+characteristics of the code being generated. Novices need not worry about
+these options since the most common options are defaulted, But advanced users
+will find it very easy to "turn the knobs" using these options.</p>
+
+<p><img border="0" src="images/tools/wsdl/OptionsPage.jpg" width="518"
+height="500"></p>
+
+<p>Once the options are taken care of, only the final step of the code
+generation is left. it is the selection of the output file location.</p>
+
+<p><img border="0" src="images/tools/wsdl/OutputPage.jpg" width="518"
+height="500"></p>
+
+<p>When the output file location is selected, the Finish button will be
+enabled. Pressing the finish button will generate the code and a message box
+will pop up acknowledging the success. Well Done! Now you are ready for Axis2
+Code generation.</p>
+
+<h1>Code Generator Wizard - Command Line Tool</h1>
+
+<h2>Introduction</h2>
+
+<p>Just as old times there will be users who wish to use the command line
+version of the tool. This basic tool is implemented by the WSDL2Code class
+and just for the convenience in the java case (which would be the majority)
+there is another WSDL2Java class. One can choose to run the main classes
+directly or use one of the scripts to run the WSDL2Code and WSDL2Java
+appropriately. (the scripts are found in the bin directory of the binary
+distribution)</p>
+
+<h2>Option Reference</h2>
+
+<table border="1" cellpadding="0" cellspacing="0"
+style="border-collapse: collapse" width="100%" id="AutoNumber1">
+  <tbody>
+    <tr>
+      <td width="50%">-uri &lt;Location of WSDL&gt;</td>
+      <td width="50%">WSDL file location. This should point to a WSDL file in
+        the local file system</td>
+    </tr>
+    <tr>
+      <td width="50%">-o &lt;output Location&gt; :</td>
+      <td width="50%">output file location. This is where the files would be
+        copied once the code generation is done. If this option is omitted
+        the generated files would be copied to the working directory.</td>
+    </tr>
+    <tr>
+      <td width="50%">-l &lt;language&gt;</td>
+      <td width="50%">Output language. Currently the code generator can
+        generate code in Java and CSharp. (CSharp support is limited) When
+        omitted defaults to Java.
+
+        <p>Allowed options are</p>
+        <ul>
+          <li>java</li>
+          <li>cs</li>
+        </ul>
+      </td>
+    </tr>
+    <tr>
+      <td width="50%">-p &lt;package name&gt;</td>
+      <td width="50%">The target package name. If omitted, a default package
+        (formed using the target  namespace of the WSDL) will be used.</td>
+    </tr>
+    <tr>
+      <td width="50%">-a</td>
+      <td width="50%">Generate code only for async style . when this option
+        is used the generated stubs will have only the asynchronous
+        invocation methods. Switched off by default.</td>
+    </tr>
+    <tr>
+      <td width="50%">-s</td>
+      <td width="50%">Generate code only for sync style . When this option is
+        used the generated stubs will have only the  synchronous invocation
+        methods. Switched off by default. When used with the -a option, this
+        takes precedence.</td>
+    </tr>
+    <tr>
+      <td width="50%">-t</td>
+      <td width="50%">Generates a test case. In the case of Java it would be
+        a junit test case. This test case will generate a dummy
+        implementation of the service and a relevant service.xml and will
+        deploy this particular service in a SimpleHttpServer. Then looking at
+        the WSDL it will generate test methods that will do web service
+        invocation both synchronously and asynchronously and test the
+        deployed service.</td>
+    </tr>
+    <tr>
+      <td width="50%">-ss</td>
+      <td width="50%">Generates server side code (i.e. skeletons). Default is
+        off</td>
+    </tr>
+    <tr>
+      <td width="50%">-sd</td>
+      <td width="50%">Generates the service descriptor (i.e. server.xml).
+        Default is off. only valid with -ss</td>
+    </tr>
+  </tbody>
+</table>
+
+<h1>Code Generator Wizard - Ant Task</h1>
+
+<p>The code generator also comes bundled with an Ant task. The ant task is
+implemented by the org.apache.axis2.tool.ant.AntCodegenTask class. Following
+are the ant task attributes.</p>
+
+<h2>Ant Task Reference</h2>
+
+<table border="1" cellpadding="0" cellspacing="0"
+style="border-collapse: collapse" width="100%" id="AutoNumber2">
+  <tbody>
+    <tr>
+      <td width="50%" height="19">wsdlfilename</td>
+      <td width="50%" height="19">WSDL file location. Maps to the uri option
+        of the command line tool</td>
+    </tr>
+    <tr>
+      <td width="50%" height="76">output</td>
+      <td width="50%" height="76">output file location. This is where the
+        files would be copied once the code generation is done. If this
+        option is omitted the generated files would be copied to the working
+        directory. . Maps to the -o option of the command line tool</td>
+    </tr>
+    <tr>
+      <td width="50%" height="171">language</td>
+      <td width="50%" height="171">Output language. Currently the code
+        generator can generate code in Java and CSharp. (CSharp support is
+        limited) When omitted defaults to Java.
+
+        <p>Allowed options are</p>
+        <ul>
+          <li>java</li>
+          <li>cs</li>
+        </ul>
+
+        <p>Maps to the -l option of the command line tool</p>
+      </td>
+    </tr>
+    <tr>
+      <td width="50%" height="57">packagename</td>
+      <td width="50%" height="57">The target package name. If omitted, a
+        default package (formed using the target  namespace of the WSDL) will
+        be used.  Maps to the -p option of the command line tool.</td>
+    </tr>
+    <tr>
+      <td width="50%" height="75">asynconly</td>
+      <td width="50%" height="75">Generate code only for async style . when
+        this option is used the generated stubs will have only the
+        asynchronous invocation methods. Defaults to false if omitted Only
+        true and false are applicable as values. Maps to the -a option of the
+        command line tool.</td>
+    </tr>
+    <tr>
+      <td width="50%" height="16">testcase</td>
+      <td width="50%" height="16">Generates a test case</td>
+    </tr>
+    <tr>
+      <td width="50%" height="19">synconly</td>
+      <td width="50%" height="19">Generate code only for sync style . when
+        this option is used the generated stubs will have only the
+        synchronous invocation methods. Defaults to false if omitted. Only
+        true and false are applicable as values. Maps to the -s option of the
+        command line tool.</td>
+    </tr>
+    <tr>
+      <td width="50%" height="19">serverside</td>
+      <td width="50%" height="19">Generates server side code (i.e.
+        skeletons). Only true and false are applicable as values. Default is
+        false. Maps to the -ss option of the command line tool</td>
+    </tr>
+    <tr>
+      <td width="50%" height="18">generateserverxml</td>
+      <td width="50%" height="18">Generates server side code (i.e.
+        skeletons). Only true and false are applicable as values. Default is
+        false. Maps to the -sd option of the command line tool.</td>
+    </tr>
+  </tbody>
+</table>
+
+<h2>Example build file using the custom Ant task</h2>
+
+<p>Following is an example ant build file that uses the custom Ant task.</p>
+
+<p></p>
+<pre>&lt;?xml version="1.0"?&gt;
+&lt;project name="CodegenExample" default="main" basedir="."&gt;
+&lt;target name="declare" &gt;
+&lt;taskdef name="codegen"
+        classname="org.apache.axis2.tool.ant.AntCodegenTask"
+        classpath="classes"/&gt;
+&lt;/target&gt;
+&lt;target name="main" depends="declare"&gt;
+&lt;codegen 
+    wsdlfilename="C:\test\wsdl\CombinedService.wsdl"
+    output="C:\"
+    serverside="true"
+    generateserverxml="true"
+/&gt;
+&lt;/target&gt;
+&lt;/project&gt;</pre>
+
+<p>Notice the main target that uses the "codegen" task which will use the
+org.apache.axis2.tool.ant.AntCodegenTask class and run the code generation
+tool internally while passing the relevant arguments and do the proper
+generation. If a user types</p>
+
+<p>&gt;ant or &gt;ant main</p>
+
+<p>it will generate the serverside code and service.xml for the given WSDL
+file(C:\test\wsdl\CombinedService.wsdl) and the generated code will be
+written to C:\ directory.</p>
+
+<p>For this Ant task to work the following jars need to be in the class
+path.</p>
+<ul>
+  <li>axis-M2.jar (from the Axis2 distribution)</li>
+  <li>axis-wsdl4j-1.2.jar (The WSDL4J implementation jar. Bundled with the
+    Axis2 distribution)</li>
+  <li>stax-api-1.0.jar (The StAX API's that contain the
+    javax.xml.namespace.QName class. This jar may be replaced by any other
+    jar that contains the javax.xml.namespace.QName implementation. However
+    Axis2 uses this class from the stax-api-1.0.jar which comes bundled with
+    the Axis2 distribution)
+    <p></p>
+  </li>
+</ul>
+
+<h1>Invoking the Code Generator from Ant</h1>
+
+<p>Since the users may find altering their ant class path a bit daunting they
+can also follow an easier technique. The code generator main class can be
+invoked directly through the build file.</p>
+<p>Below is an example of a full build.xml needed to run WSDL2Java and generate the
Java source files, compile the sources, and build an AAR file ready for deployment: </p>
+<pre class="code">&lt;!DOCTYPE project&gt;
+
+&lt;project name="wsdl2java-example" default="usage" basedir="."&gt;
+
+  &lt;property name="project-name" value="wsdl2java-example"/&gt;
+  &lt;property file="build.properties"/&gt;
+  
+  &lt;property name="build" value="build"/&gt;
+
+  &lt;property name="src" value="src"/&gt;
+  &lt;property name="build.classes"      value="build/classes" /&gt;
+
+  &lt;path id="axis.classpath"&gt;
+     &lt;pathelement location="build/classes" /&gt;
+     &lt;fileset dir="${axis.home}/lib"&gt;
+       &lt;include name="**/*.jar" /&gt;
+
+     &lt;/fileset&gt;
+     &lt;pathelement location="${build.classes}" /&gt;
+  &lt;/path&gt;
+
+  &lt;target name="usage" description="Build file usage info (default task)"&gt;
+    &lt;echo message=" " /&gt;
+    &lt;echo message="${project-name} " /&gt;
+
+    &lt;echo message="-------------------------------------------------------" /&gt;
+    &lt;echo message=" " /&gt;
+    &lt;echo message="Available Targets:" /&gt;
+    &lt;echo message=" " /&gt;
+    &lt;echo message=" Compiling:" /&gt;
+    &lt;echo message="  compile           - Compiles the WSDL2Java source code" /&gt;
+
+    &lt;echo message=" " /&gt;
+    &lt;echo message=" Compiling client:" /&gt;
+    &lt;echo message="  compile_client           - Compiles the client source code" /&gt;
+    &lt;echo message=" " /&gt;
+    &lt;echo message=" Cleaning up:" /&gt;
+    &lt;echo message="  clean             - Delete class files" /&gt;
+
+    &lt;echo message=" " /&gt;
+    &lt;echo message=" WSDL:" /&gt;
+    &lt;echo message="  wsdl2java               - Generate source from WSDL" /&gt;
+    &lt;echo message=" " /&gt;
+    &lt;echo message=" AAR:" /&gt;
+    &lt;echo message="  aar               - Generate an .aar for deployment into WEB-INF/services"
/&gt;
+
+    &lt;echo message=" " /&gt;
+    &lt;echo message=" Executing:" /&gt;
+    &lt;echo message="  runLogin               - Execute the runLogin client" /&gt;
+  &lt;/target&gt;
+
+  &lt;target name="prepare" &gt;
+    &lt;mkdir dir="${build.classes}" /&gt;
+
+  &lt;/target&gt;
+
+  &lt;target name="clean" &gt;
+     &lt;delete dir="${build}" /&gt;
+     &lt;delete dir="${dist}" /&gt;
+  &lt;/target&gt;
+
+  &lt;target name="compile"&gt;
+    &lt;echo message="Compiling wsdl2 files"/&gt;
+
+    &lt;javac
+     srcdir="output"
+     destdir="${build.classes}"
+     deprecation="true"
+     failonerror="true" debug="true"
+    &gt;
+
+     &lt;classpath refid="axis.classpath"/&gt; 
+    &lt;/javac&gt;
+
+  &lt;/target&gt;
+
+  &lt;target name="wsdl2java" depends="clean,prepare"&gt;
+      &lt;delete dir="output" /&gt;
+      &lt;java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"&gt;
+          &lt;classpath refid="axis.classpath"/&gt; 
+          &lt;arg value="-uri"/&gt;
+
+          &lt;arg file="wsdl/LoginEndpoint.wsdl"/&gt;
+          &lt;arg value="-ss"/&gt;
+          &lt;arg value="-sd"/&gt;
+          &lt;arg value="-o"/&gt;
+          &lt;arg file="output"/&gt;
+          &lt;arg value="-p"/&gt;
+
+          &lt;arg value="org.example.types"/&gt;
+      &lt;/java&gt;
+
+      &lt;!-- Move the schema folder to classpath--&gt;
+      &lt;move todir="${build.classes}"&gt;
+          &lt;fileset dir="output"&gt;
+              &lt;include name="**/*schema*/**/*.class"/&gt;
+
+              &lt;include name="**/*schema*/**/*.xsb"/&gt;
+          &lt;/fileset&gt;
+      &lt;/move&gt;
+
+  &lt;/target&gt;
+
+  &lt;target name="jar_wsdl" depends="compile"&gt;
+
+  &lt;jar jarfile="lib/axis2_example_wsdl.jar" &gt;
+  &lt;fileset dir="${build}/classes" /&gt;
+  &lt;/jar&gt;
+  &lt;/target&gt;
+  
+  &lt;!-- build an .aar file for axis2 web services --&gt;
+  &lt;target name="aar" depends="compile"&gt;
+
+     &lt;delete dir="${build.classes}/META-INF" /&gt;
+     &lt;mkdir dir="${build.classes}/META-INF" /&gt;
+     &lt;copy todir="${build.classes}/META-INF" &gt;
+       &lt;fileset dir="output/service_descriptors/LoginEndpoint" &gt;
+         &lt;!-- axis2 web services definitions file --&gt;
+         &lt;include name="services.xml"/&gt;
+
+       &lt;/fileset&gt;
+       &lt;fileset dir="wsdl" &gt;
+         &lt;include name="LoginEndpoint.wsdl"/&gt;
+       &lt;/fileset&gt;
+     &lt;/copy&gt;
+     &lt;jar jarfile="dist/LoginEndpoint.aar" &gt;
+
+       &lt;fileset dir="${build.classes}" /&gt;
+     &lt;/jar&gt;
+  &lt;/target&gt;
+
+  &lt;target name="compile_client"&gt;
+    &lt;echo message="Compiling client files"/&gt;
+
+    &lt;javac
+     srcdir="src"
+     destdir="${build.classes}"
+     deprecation="true"
+     failonerror="true" debug="true"
+    &gt;
+
+     &lt;classpath refid="axis.classpath"/&gt; 
+    &lt;/javac&gt;
+
+  &lt;/target&gt;
+
+  &lt;target name="runLogin" depends="compile_client" description="run webLogin client"&gt;
+
+     &lt;echo message="running the webLogin client" /&gt;
+     &lt;java classname="org.client.LoginClient" &gt;
+      &lt;classpath refid="axis.classpath"/&gt; 
+    &lt;/java&gt;
+  &lt;/target&gt;
+
+&lt;/project&gt;
+
+</pre>
+
+<p>The above build.xml depends on a build.properties file which defines 'axis.home',
such as:</p>
+<p>axis.home=/home/username/axis2-0.93-bin/</p>
+
+<p>The above build.xml example also assumes three empty directories exist, 'dist',
'lib', and 'src'. </p>
+
+<p>Below is a validated WSDL Document following the Document/Literal Style. The name
of this file matches the name used in the WSDL2Java ant task above, LoginEndpoint.wsdl</p>
+<pre class="code">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+
+&lt;definitions name="LoginService" targetNamespace="http://login" xmlns:tns="http://login"
xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ns2="http://login/types"&gt;
+
+  &lt;types&gt;
+    &lt;schema targetNamespace="http://login/types" xmlns:tns="http://login/types" xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://www.w3.org/2001/XMLSchema"&gt;
+      &lt;import namespace="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
+      &lt;element name="returnWebLoginElement"&gt;
+        &lt;complexType&gt;
+          &lt;sequence&gt;
+
+            &lt;element ref="tns:soap_session_idElement"/&gt;
+            &lt;element ref="tns:web_user_nameElement"/&gt;
+          &lt;/sequence&gt;
+        &lt;/complexType&gt;
+      &lt;/element&gt;
+      &lt;element name="webLoginElement"&gt;
+
+        &lt;complexType&gt;
+          &lt;sequence&gt;
+            &lt;element ref="tns:user_nameElement"/&gt;
+            &lt;element ref="tns:user_passwordElement"/&gt;
+          &lt;/sequence&gt;
+        &lt;/complexType&gt;
+
+      &lt;/element&gt;
+      &lt;element name="user_nameElement" type="xsd:string"/&gt;
+      &lt;element name="user_passwordElement" type="xsd:string"/&gt;
+      &lt;element name="soap_session_idElement" type="xsd:string"/&gt;
+      &lt;element name="web_user_nameElement" type="xsd:string"/&gt;
+&lt;/schema&gt;&lt;/types&gt;
+
+  &lt;message name="LoginEndpoint_webLogin"&gt;
+     &lt;part name="parameters" element="ns2:webLoginElement"/&gt;
+  &lt;/message&gt;
+  &lt;message name="LoginEndpoint_webLoginResponse"&gt;
+    &lt;part name="result" element="ns2:returnWebLoginElement"/&gt;
+  &lt;/message&gt;
+
+  &lt;portType name="LoginEndpoint"&gt;
+    &lt;operation name="webLogin"&gt;
+      &lt;input message="tns:LoginEndpoint_webLogin" name="LoginEndpoint_webLogin"/&gt;
+      &lt;output message="tns:LoginEndpoint_webLoginResponse" name="LoginEndpoint_webLoginResponse"/&gt;
+    &lt;/operation&gt;
+  &lt;/portType&gt;
+
+  &lt;binding name="LoginEndpointBinding" type="tns:LoginEndpoint"&gt;
+    &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/&gt;
+    &lt;operation name="webLogin"&gt;
+      &lt;soap:operation soapAction="webLogin"/&gt;
+      &lt;input name="LoginEndpoint_webLogin"&gt;
+        &lt;soap:body use="literal"/&gt;
+
+      &lt;/input&gt;
+      &lt;output name="LoginEndpoint_webLoginResponse"&gt; 
+        &lt;soap:body use="literal"/&gt;
+      &lt;/output&gt;
+    &lt;/operation&gt;
+  &lt;/binding&gt;
+
+  &lt;service name="LoginService"&gt;
+    &lt;port name="LoginEndpointPort" binding="tns:LoginEndpointBinding"&gt;
+      &lt;soap:address location="http://localhost:8080/axis2/services/LoginEndpoint"/&gt;&lt;/port&gt;&lt;/service&gt;&lt;/definitions&gt;
+</pre>
+<p>Place the above file, named LoginEndpoint.wsdl, in the directory 'wsdl' below the
build.xml file. Run the WSDL2Java command via the ant task defined above, and there will be
a directory called 'output' created. This directory contains the WSDL2Java generated source.
An important detail is that an XMLBean class file is also generated by WSDL2Java, TypeSystemHolder.class.
That file is placed into build/classes by the above ant task and will be needed to compile
the generated sources.</p> 
+<p>The next step is to modify the generated Skeleton Java Source file - the Web Service.
This file as generated returns null and needs to be updated to contain the business logic.</p>

+
+<p>After the WSDL2Java command runs the file LoginEndpoint.wsdl, edit the following
file:</p> 
+<p>output/org/example/types/LoginEndpointSkeleton.java. You should see the following
code:</p> 
+<pre class="code">package org.example.types;
+    /**
+     *  Auto generated java skeleton for the service by the Axis code generator
+     */
+    public class LoginEndpointSkeleton {
+     
+ 
+        /**
+         * Auto generated method signature
+         
+          * @param param0
+         
+         */
+        public  org.example.types.databinding.login.ReturnWebLoginElementDocument webLogin
+                  (org.example.types.databinding.login.WebLoginElementDocument param0 ){
+                //Todo fill this with the necessary business logic
+                return null;
+        }
+     
+    }
+</pre>    
+<p>Replace the contents of this file with the following, which uses the complex types
generated by WSDL2Java and the example wsdl file:</p> 
+<pre class="code">package org.example.types;
+import org.example.types.databinding.login.ReturnWebLoginElementDocument;
+import org.example.types.databinding.login.WebLoginElementDocument.WebLoginElement;
+
+/**
+ *  Auto generated java skeleton for the service by the Axis code generator
+ */
+public class LoginEndpointSkeleton {
+ 
+    /**
+     * Auto generated method signature
+     
+      * @param webLoginElementDocument changed from param0
+     
+     */
+    public  org.example.types.databinding.login.ReturnWebLoginElementDocument webLogin
+              (org.example.types.databinding.login.WebLoginElementDocument webLoginElementDocument
){
+
+            //Todo fill this with the necessary business logic
+            System.out.println("LoginEndpointSkeleton.webLogin reached successfully!");
+
+            // Get parameters passed in 
+            WebLoginElement webLoginElement = webLoginElementDocument.getWebLoginElement();
+            String userName = webLoginElement.getUserNameElement();
+            String password = webLoginElement.getUserPasswordElement();
+            System.out.println("LoginEndpointSkeleton.webLogin userName: " + userName);
+            System.out.println("LoginEndpointSkeleton.webLogin password: " + password);
+     
+            // input paramaters would be used here 
+    
+            // prepare output
+            org.example.types.databinding.login.ReturnWebLoginElementDocument retDoc =
+                org.example.types.databinding.login.ReturnWebLoginElementDocument.Factory.newInstance();
+            
+            org.example.types.databinding.login.ReturnWebLoginElementDocument.ReturnWebLoginElement
+            retElement =
+             org.example.types.databinding.login.ReturnWebLoginElementDocument.ReturnWebLoginElement.Factory.newInstance();
+            
+            retElement.setWebUserNameElement("joe sixpack");
+            retElement.setSoapSessionIdElement("some_random_string");
+            System.out.println("validate retElement: " + retElement.validate());
+
+            retDoc.setReturnWebLoginElement(retElement);
+            System.out.println("validate retDoc: " + retDoc.validate());
+            
+            System.out.println("LoginEndpointSkeleton.webLogin returning...");
+    
+            return retDoc; 
+    
+
+    }
+ 
+}
+
+</pre>
+<p>The next steps assume the axis2.war has been deployed and has expanded in a servlet
container. </p> 
+<p>Run the 'jar_wsdl' ant task from the example build.xml, which generates a jar file
lib/axis2_example_wsdl.jar in the 'lib' directory under the build.xml . This jar will be used
to compile the client, and also will be placed in the servlet container. Next, run the 'aar'
ant task from the example build.xml, which generates the deployable axis2 web service. Place
dist/LoginEndpoint.aar into axis2/WEB-INF/services . Place lib/axis2_example_wsdl.jar into
axis2/WEB-INF/lib . Verify the happy axis page loaded the services correctly - there should
be the service 'LoginEndpoint' with the available operation 'webLogin' displayed.</p>

+
+<p>The last step is to create and run the client. In the src directory create the file
org.client.LoginClient.java, with the contents below:</p> 
+<pre class="code">package org.client;
+
+import org.apache.axis2.AxisFault;
+
+import org.example.types.LoginEndpointStub;
+import org.example.types.databinding.login.WebLoginElementDocument;
+import org.example.types.databinding.login.WebLoginElementDocument.WebLoginElement;
+import org.example.types.databinding.login.ReturnWebLoginElementDocument;
+import org.example.types.databinding.login.WebLoginElementDocument;
+import org.example.types.databinding.login.WebLoginElementDocument.WebLoginElement;
+
+/**
+ * Login.
+ *
+ */
+public class LoginClient {
+
+    public static void main(String[] args) {
+        try {
+
+            System.out.println("webLogin, firing...");
+            LoginEndpointStub stub = 
+                new LoginEndpointStub(null, 
+                    "http://localhost:8080/axis2/services/LoginEndpoint");
+                    
+            WebLoginElementDocument webLoginElementDocument 
+                = WebLoginElementDocument.Factory.newInstance();
+            WebLoginElement webLoginElement = 
+                WebLoginElement.Factory.newInstance();
+            webLoginElement.setUserNameElement("joe");
+            webLoginElement.setUserPasswordElement("sixpack");
+            
+            webLoginElementDocument.setWebLoginElement(webLoginElement);
+            
+            System.out.println("validate: " +  webLoginElement.validate());
+             stub.webLogin(webLoginElementDocument);
+ 
+            ReturnWebLoginElementDocument returnWebLoginElementDocument = 
+                stub.webLogin(webLoginElementDocument);
+
+            System.out.println("Client returned");
+
+            org.example.types.databinding.login.ReturnWebLoginElementDocument.ReturnWebLoginElement
+                retElement = returnWebLoginElementDocument.getReturnWebLoginElement();
+
+            System.out.println("WebUserName: " + retElement.getWebUserNameElement());
+            System.out.println("SOAPSessionId: " + retElement.getSoapSessionIdElement());
+            System.out.println("webLogin, completed!!!");
+
+        } catch (AxisFault axisFault) {
+            axisFault.printStackTrace();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+}
+
+
+</pre>
+<p>Now run the ant task 'ant runLogin' . The following output should appear: </p>

+<pre class="code">runLogin:
+     [echo] running the webLogin client
+     [java] webLogin, firing...
+     [java] validate: true
+     [java] Client returned
+     [java] WebUserName: joe sixpack
+     [java] SOAPSessionId: some_random_string
+     [java] webLogin, completed!!!
+</pre>
+<p></p>
+
+<h1>Appendix</h1>
+<ul>
+  <li>Eclipse reference - <a href="http://www.eclipse.org/">
+    http://www.eclipse.org/</a></li>
+  <li>Custom Ant Tasks  - <a
+    href="http://ant.apache.org/manual/develop.html">
+    http://ant.apache.org/manual/develop.html</a></li>
+</ul>
+
+<p> </p>
+
+<p> </p>
+
+<p> </p>
+
+<p> </p>
+
+<p> </p>
+</body>
+</html>



Mime
View raw message