cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > Java to WS
Date Sat, 31 Dec 2011 18:16:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Java+to+WS">Java
to WS</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~mazzag">Glen
Mazza</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        added info on Antbuild sample<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Make sure you set the &quot;fork=true&quot;
attribute for the &lt;java/&gt; task as shown above.  Also, remember to keep each
word or flag within the command line options in its own &lt;arg/&gt; element (e.g.,
do not use &lt;arg value=&quot;-o hello.wsdl&quot;/&gt;, but split them up
into two &lt;arg/&gt; elements as done here.) <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Although
we would recommend using Maven, see the [antbuild sample|http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/antbuild/]
in the CXF distribution for an example of using Ant to create a CXF project. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. See Also <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="JavatoWS-JavatoWS"></a>Java to WS</h2>

<h3><a name="JavatoWS-Name"></a>Name</h3>

<p><tt>java2ws</tt> - uses a Web service endpoint's implementation (SEI)
class and associated types classes to generate a WSDL file, wrapper bean ,server side code
to start the web service and client side code.</p>

<h3><a name="JavatoWS-Synopsis"></a>Synopsis</h3>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>   java2ws -databinding &lt;jaxb or aegis&gt; -frontend &lt;jaxws or
simple&gt; 
           -wsdl -wrapperbean -client -server -ant -o &lt;output-file&gt;
           -d &lt;resource-directory&gt; -classdir &lt;compile-classes-directory&gt;

           -cp &lt;class-path&gt; -soap12 -t &lt;target-namespace&gt; 
           -beans &lt;ppathname of the bean definition file&gt;* 
           -address &lt;port-address&gt; -servicename &lt;service-name&gt;

           -portname &lt;port-name&gt; -createxsdimports -h -v -verbose 
           -quiet {classname}
</pre>
</div></div>

<h3><a name="JavatoWS-Description"></a>Description</h3>

<p>  <b>java2ws</b> uses a Web service endpoint's implementation (SEI) class
and associated types classes to generate a WSDL file, wrapper bean ,server side code to start
the web service and client side code.</p>

<h3><a name="JavatoWS-Options"></a>Options</h3>

<p>The options used to manage the code generation process are reviewed in the following
table.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Interpretation </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>-?</tt>,<tt>-h</tt>,<tt>-help</tt>
</td>
<td class='confluenceTd'> Displays the online help for this utility and exits. </td>
</tr>
<tr>
<td class='confluenceTd'> -o </td>
<td class='confluenceTd'> Specifies the name of the generated WSDL file. </td>
</tr>
<tr>
<td class='confluenceTd'> --databinding</td>
<td class='confluenceTd'>Specify the data binding (aegis or jaxb). Default is jaxb for
jaxws frontend, and aegis for simple frontend.</td>
</tr>
<tr>
<td class='confluenceTd'>-frontend</td>
<td class='confluenceTd'> Specify the frontend to use.  jaxws and the simple frontend
are supported.</td>
</tr>
<tr>
<td class='confluenceTd'>-wsdl</td>
<td class='confluenceTd'>Specify to generate the WSDL file.</td>
</tr>
<tr>
<td class='confluenceTd'>-wrapperbean</td>
<td class='confluenceTd'>Specify to generate the wrapper and fault bean</td>
</tr>
<tr>
<td class='confluenceTd'>-client</td>
<td class='confluenceTd'>Specify to generate client side code</td>
</tr>
<tr>
<td class='confluenceTd'>-server</td>
<td class='confluenceTd'>Specify to generate server side code</td>
</tr>
<tr>
<td class='confluenceTd'>-ant</td>
<td class='confluenceTd'>Specify to generate an Ant build.xml script</td>
</tr>
<tr>
<td class='confluenceTd'> -cp </td>
<td class='confluenceTd'> Specify the SEI and types class search path of directories
and zip/jar files. </td>
</tr>
<tr>
<td class='confluenceTd'> -soap12 </td>
<td class='confluenceTd'> Specifies that the generated WSDL is to include a SOAP 1.2
binding. </td>
</tr>
<tr>
<td class='confluenceTd'> -t </td>
<td class='confluenceTd'> Specifies the target namespace to use in the generated WSDL
file. </td>
</tr>
<tr>
<td class='confluenceTd'> -servicename </td>
<td class='confluenceTd'> Specifies the value of the generated service element's name
attribute. </td>
</tr>
<tr>
<td class='confluenceTd'> -v </td>
<td class='confluenceTd'> Displays the version number for the tool. </td>
</tr>
<tr>
<td class='confluenceTd'> -verbose </td>
<td class='confluenceTd'> Displays comments during the code generation process. </td>
</tr>
<tr>
<td class='confluenceTd'> -quiet </td>
<td class='confluenceTd'> Suppresses comments during the code generation process. </td>
</tr>
<tr>
<td class='confluenceTd'> -s </td>
<td class='confluenceTd'> The directory in which the generated source files(wrapper
bean ,fault bean ,client side or server side code) are placed.</td>
</tr>
<tr>
<td class='confluenceTd'> -classdir </td>
<td class='confluenceTd'> The directory in which the generated sources are compiled
into.  If not specified, the files are not compiled. </td>
</tr>
<tr>
<td class='confluenceTd'> -portname</td>
<td class='confluenceTd'> Specify the port name to use in the generated wsdl. </td>
</tr>
<tr>
<td class='confluenceTd'> -address</td>
<td class='confluenceTd'> Specify the port address. </td>
</tr>
<tr>
<td class='confluenceTd'> -beans</td>
<td class='confluenceTd'>Specify the pathname of a file defining additional Spring beans
to customize databinding configuration.</td>
</tr>
<tr>
<td class='confluenceTd'> -createxsdimports</td>
<td class='confluenceTd'>Output schemas to separate files and use imports to load them
instead of inlining them into the wsdl. </td>
</tr>
<tr>
<td class='confluenceTd'> -d </td>
<td class='confluenceTd'> The directory in which the resource files are placed, wsdl
file will be placed into this directory by default</td>
</tr>
<tr>
<td class='confluenceTd'> classname </td>
<td class='confluenceTd'> Specifies the name of the SEI class. </td>
</tr>
</tbody></table>
</div>

<p>You must include the <tt>classname</tt> argument. All other arguments
are optional and may be listed in any order. This tool will search and load the service endpoint
class and types classes. Make certain these classes are on the <tt>CLASSPATH</tt>
or in a location identified through the <tt>-cp</tt> flag. If none of "-wsdl ,
- wrapperbean, -client, -server" flags are specified, java2ws will generate nothing.</p>

<p><a name="JavatoWS-usingant"></a></p>

<h3><a name="JavatoWS-Examples"></a>Examples</h3>

<p>   <tt>java2ws -wsdl -d ./resource org.apache.hello.Greeter</tt><br/>
   <tt>java2ws -cp ./tmp org.apache.hello.Greeter -wsdl</tt> <br/>
   <tt>java2ws -o hello.wsdl -wsdl org.apache.hello.Greeter</tt> <br/>
   <tt>java2ws -client -server -s ./src org.apache.hello.Greeter</tt><br/>
   <tt>java2ws -wrapperbean -classdir ./classes org.apache.hello.Greeter</tt></p>

<h3><a name="JavatoWS-Usingjava2wswithAnt"></a>Using java2ws with Ant</h3>

<p>The java2ws command can be wrapped inside an Ant target as shown below:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>?&gt;</span>
<span class="code-tag">&lt;project name=<span class="code-quote">"cxf java2ws"</span>
basedir=<span class="code-quote">"."</span>&gt;</span>   
   <span class="code-tag">&lt;property name=<span class="code-quote">"cxf.home"</span>
location =<span class="code-quote">"/usr/myapps/cxf-trunk"</span>/&gt;</span>
   <span class="code-tag">&lt;property name=<span class="code-quote">"build.classes.dir"</span>
location =<span class="code-quote">"${basedir}/build/classes"</span>/&gt;</span>

   <span class="code-tag">&lt;path id=<span class="code-quote">"cxf.classpath"</span>&gt;</span>
      <span class="code-tag">&lt;pathelement location=<span class="code-quote">"${build.classes.dir}"</span>/&gt;</span>
      <span class="code-tag">&lt;fileset dir=<span class="code-quote">"${cxf.home}/lib"</span>&gt;</span>
         <span class="code-tag">&lt;include name=<span class="code-quote">"*.jar"</span>/&gt;</span>
      <span class="code-tag">&lt;/fileset&gt;</span>
   <span class="code-tag">&lt;/path&gt;</span>
      
   <span class="code-tag">&lt;target name=<span class="code-quote">"cxfJavaToWS"</span>&gt;</span>
      <span class="code-tag">&lt;java classname=<span class="code-quote">"org.apache.cxf.tools.java2ws.JavaToWS"</span>
fork=<span class="code-quote">"true"</span>&gt;</span>
         <span class="code-tag">&lt;arg value=<span class="code-quote">"-wsdl"</span>/&gt;</span>
         <span class="code-tag">&lt;arg value=<span class="code-quote">"-o"</span>/&gt;</span>
         <span class="code-tag">&lt;arg value=<span class="code-quote">"hello.wsdl"</span>/&gt;</span>
         <span class="code-tag">&lt;arg value=<span class="code-quote">"service.Greeter"</span>/&gt;</span>
         <span class="code-tag">&lt;classpath&gt;</span>
            <span class="code-tag">&lt;path refid=<span class="code-quote">"cxf.classpath"</span>/&gt;</span>
         <span class="code-tag">&lt;/classpath&gt;</span>
      <span class="code-tag">&lt;/java&gt;</span>
   <span class="code-tag">&lt;/target&gt;</span>
<span class="code-tag">&lt;/project&gt;</span>
</pre>
</div></div>

<p>Make sure you set the "fork=true" attribute for the &lt;java/&gt; task as
shown above.  Also, remember to keep each word or flag within the command line options in
its own &lt;arg/&gt; element (e.g., do not use &lt;arg value="-o hello.wsdl"/&gt;,
but split them up into two &lt;arg/&gt; elements as done here.)</p>

<p>Although we would recommend using Maven, see the <a href="http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/antbuild/"
class="external-link" rel="nofollow">antbuild sample</a> in the CXF distribution
for an example of using Ant to create a CXF project.</p>

<h3><a name="JavatoWS-SeeAlso"></a>See Also</h3>

<p><a href="/confluence/display/CXF20DOC/IDL+to+WSDL" title="IDL to WSDL"><tt>idl2wsdl</tt></a>,
<a href="/confluence/display/CXF20DOC/Java+to+Javascript" title="Java to Javascript"><tt>java2js</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDL+to+CORBA" title="WSDL to CORBA"><tt>wsdl2corba</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDL+to+Java" title="WSDL to Java"><tt>wsdl2java</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDL+to+Javascript" title="WSDL to Javascript"><tt>wsdl2js</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDL+to+Service" title="WSDL to Service"><tt>wsdl2service</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDL+to+SOAP" title="WSDL to SOAP"><tt>wsdl2soap</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDL+to+XML" title="WSDL to XML"><tt>wsdl2xml</tt></a>,
<a href="/confluence/display/CXF20DOC/WSDLValidator" title="WSDLValidator"><tt>wsdlvalidator</tt></a>
and <a href="/confluence/display/CXF20DOC/XSD+to+WSDL" title="XSD to WSDL">xsd2wsdl</a>.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Java+to+WS">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=67213&revisedVersion=22&originalVersion=21">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Java+to+WS?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message