| <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
|
| "New" section.(use the File -> New -> 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 "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" bordercolor="#111111" width="100%" id="AutoNumber1">
|
| <tr>
|
| <td width="50%">-uri <Location of WSDL></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 <output Location> : </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 <language></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 <package name> </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>
|
| </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 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>
|
| </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><?xml version="1.0"?>
|
| <project name="CodegenExample" default="main" basedir=".">
|
| <target name="declare" >
|
| <taskdef name="codegen"
|
| classname="org.apache.axis2.tool.ant.AntCodegenTask"
|
| classpath="classes"/>
|
| </target>
|
| <target name="main" depends="declare">
|
| <codegen
|
| wsdlfilename="C:\test\wsdl\CombinedService.wsdl"
|
| output="C:\"
|
| serverside="true"
|
| generateserverxml="true"
|
| />
|
| </target>
|
| </project></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 -
|
| <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> |