blob: fbd333903d20157e885b61e301e7d5fef5033adc [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<link type="text/css" rel="stylesheet" href="/resources/site.css">
<script src='/resources/space.js'></script>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
<meta name="description" content="Apache CXF, Services Framework - Java to WSDL">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shCoreCXF.css">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
<script src='/resources/highlighter/scripts/shBrushBash.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
<title>
Apache CXF -- Java to WSDL
</title>
</head>
<body onload="init()">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td id="cell-0-0" colspan="2">&nbsp;</td>
<td id="cell-0-1">&nbsp;</td>
<td id="cell-0-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-1-0">&nbsp;</td>
<td id="cell-1-1">&nbsp;</td>
<td id="cell-1-2">
<!-- Banner -->
<div class="banner" id="banner"><div><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
<a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
</td><td align="right" colspan="1" nowrap>
<a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
</td></tr></table></div></div>
<!-- Banner -->
<div id="top-menu">
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td>
<div align="left">
<!-- Breadcrumbs -->
<a href="index.html">Index</a>&nbsp;&gt;&nbsp;<a href="tools.html">Tools</a>&nbsp;&gt;&nbsp;<a href="java-to-wsdl.html">Java to WSDL</a>
<!-- Breadcrumbs -->
</div>
</td>
<td>
<div align="right">
<!-- Quicklinks -->
<div id="quicklinks"><p><a shape="rect" href="http://cxf.apache.org/download.html">Download</a> | <a shape="rect" href="http://cxf.apache.org/docs/index.html">Documentation</a></p></div>
<!-- Quicklinks -->
</div>
</td>
</tr>
</table>
</div>
</td>
<td id="cell-1-3">&nbsp;</td>
<td id="cell-1-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-2-0" colspan="2">&nbsp;</td>
<td id="cell-2-1">
<table>
<tr valign="top">
<td height="100%">
<div id="wrapper-menu-page-right">
<div id="wrapper-menu-page-top">
<div id="wrapper-menu-page-bottom">
<div id="menu-page">
<!-- NavigationBar -->
<div id="navigation"><ul class="alternate"><li><a shape="rect" href="overview.html">Overview</a></li><li><a shape="rect" href="how-tos.html">How-Tos</a></li><li><a shape="rect" href="frontends.html">Frontends</a></li><li><a shape="rect" href="databindings.html">DataBindings</a></li><li><a shape="rect" href="transports.html">Transports</a></li><li><a shape="rect" href="configuration.html">Configuration</a></li><li><a shape="rect" href="debugging-and-logging.html">Debugging and Logging</a></li><li><a shape="rect" href="tools.html">Tools</a></li><li><a shape="rect" href="restful-services.html">RESTful Services</a></li><li><a shape="rect" href="wsdl-bindings.html">WSDL Bindings</a></li><li><a shape="rect" href="service-routing.html">Service Routing</a></li><li><a shape="rect" href="dynamic-languages.html">Dynamic Languages</a></li><li><a shape="rect" href="ws-support.html">WS-* Support</a></li><li><a shape="rect" href="advanced-integration.html">Advanced Integration</a></li><li><a shape="rect" href="deployment.html">Deployment</a></li><li><a shape="rect" href="schemas-and-namespaces.html">Use of Schemas and Namespaces</a></li></ul><hr><ul class="alternate"><li><p>Search</p></li></ul><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="002890367768291051730:o99qiwa09y4">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" size="21">
<input type="submit" name="sa" value="Search">
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script><hr><ul class="alternate"><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest/">API 3.2.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest-3.1.x/">API 3.1.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/">CXF Website</a></li></ul><p>&#160;</p><p><a shape="rect" class="external-link" href="http://www.apache.org/events/current-event.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.apache.org/events/current-event-125x125.png" data-image-src="http://www.apache.org/events/current-event-125x125.png"></span></a></p></div>
<!-- NavigationBar -->
</div>
</div>
</div>
</div>
</td>
<td height="100%">
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><h2 id="JavatoWSDL-Synopsis">Synopsis</h2>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">
java2wsdl [-?|-help|-h][-o &lt;output-file&gt;][-cp &lt;class-path&gt;][-soap12][-t &lt;target-namespace&gt;][-servicenam &lt;seservice-name&gt;][-v][-verbose|-quiet][-s &lt;source-directory&gt;]
[-classdir &lt;compile-classes-directory&gt;][-portname &lt;port-name&gt;][-createxsdimports][-d &lt;output-directory&gt;] { classname }
</pre>
</div></div>
<h2 id="JavatoWSDL-Description">Description</h2>
<p><strong>java2wsdl</strong> uses a compiled Web service endpoint's implementation (SEI) class and associated types classes to generate a WSDL file.</p>
<p><strong><em>Note: java2wsdl is available only for the current production 2.0.x series of CXF. For the upcoming 2.1 versions, please use java2ws instead.</em></strong></p>
<h2 id="JavatoWSDL-Example">Example</h2>
<p>java2wsdl org.apache.hello_world_soap_http.Greeter </p>
<p>java2wsdl -cp ./tmp org.apache.hello_world_soap_http.Greeter </p>
<p>java2wsdl -o hello.wsdl org.apache.hello_world_soap_http.Greeter </p>
<p>java2wsdl -o hello.wsdl -t <a shape="rect" href="http://cxf.apache.org">http://cxf.apache.org</a> org.apache.hello_world_soap_http.Greeter</p>
<p>(See below for usage with Apache <a shape="rect" href="java-to-wsdl.html">Ant</a> and <a shape="rect" href="java-to-wsdl.html">Maven</a>.)</p>
<h2 id="JavatoWSDL-Arguments">Arguments</h2>
<p>The arguments used to manage the WSDL file generation are reviewed in the following table.</p>
<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Interpretation</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -? </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Displays the online help for this utility. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -help </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -h </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -o </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specifies the name of the generated WSDL file. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -cp </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specify the SEI and types class search path of directories and zip/jar files. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -soap12 </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specifies that the generated WSDL is to include a SOAP 1.2 binding. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -t </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specifies the target namespace to use in the generated WSDL file. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -servicename </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specifies the value of the generated service element's name attribute. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -v </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Displays the version number for the tool. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -verbose </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Displays comments during the code generation process. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -quiet </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Suppresses comments during the code generation process. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -s </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The directory in which the generated source files are placed, mostly in jaxws mode, it will generate the wrapper beans and fault beans </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -classdir </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The directory in which the generated sources are compiled into. If not specified, the files are not compiled. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -portname</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specify the port name to use in the generated wsdl. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -createxsdimports</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Output schemas to separate files and use imports to load them instead of inlining them into the wsdl. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> -d </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The directory in which the output files are placed. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> classname </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Specifies the name of the SEI class. Note this is the compiled class, not a reference to its source file. </p></td></tr></tbody></table></div>
<p>You must include the <code>classname</code> 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 <code>CLASSPATH</code> or in a location identified through the <code>-cp</code> flag.</p>
<p><span class="confluence-anchor-link" id="JavatoWSDL-usingant"></span></p>
<h2 id="JavatoWSDL-Usingjava2wsdlwithAnt">Using java2wsdl with Ant</h2>
<p>The java2wsdl command can be wrapped inside an Ant target as shown below:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">
&lt;?xml version="1.0"?&gt;
&lt;project name="cxf java2wsdl" basedir="."&gt;
&lt;property name="cxf.home" location ="/usr/myapps/cxf-2.0.1"/&gt;
&lt;property name="build.classes.dir" location ="${basedir}/build/classes"/&gt;
&lt;path id="cxf.classpath"&gt;
&lt;pathelement location="${build.classes.dir}"/&gt;
&lt;fileset dir="${cxf.home}/lib"&gt;
&lt;include name="*.jar"/&gt;
&lt;/fileset&gt;
&lt;/path&gt;
&lt;target name="cxfJavaToWSDL"&gt;
&lt;java classname="org.apache.cxf.tools.java2wsdl.JavaToWSDL" fork="true"&gt;
&lt;arg value="-o"/&gt;
&lt;arg value="hello.wsdl"/&gt;
&lt;arg value="service.Greeter"/&gt;
&lt;classpath&gt;
&lt;path refid="cxf.classpath"/&gt;
&lt;/classpath&gt;
&lt;/java&gt;
&lt;/target&gt;
&lt;/project&gt;
</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><span class="confluence-anchor-link" id="JavatoWSDL-usingmaven"></span></p>
<h2 id="JavatoWSDL-MavenPlugins">Maven Plugins</h2>
<p>In CXF we have a Maven plugin, called "cxf-codegen-plugin", which includes a "java2wsdl" goal. You can find more information in <a shape="rect" href="using-cxf-with-maven.html">Using CXF with maven</a>.</p></div>
</div>
<!-- Content -->
</td>
</tr>
</table>
</td>
<td id="cell-2-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-3-0">&nbsp;</td>
<td id="cell-3-1">&nbsp;</td>
<td id="cell-3-2">
<div id="footer">
<!-- Footer -->
<div id="site-footer">
<a href="http://cxf.apache.org/privacy-policy.html">Privacy Policy</a> -
(<a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=32901">edit page</a>)
(<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=32901&amp;showComments=true&amp;showCommentArea=true#addcomment">add comment</a>)<br>
Apache CXF, CXF, Apache, the Apache feather logo are trademarks of The Apache Software Foundation.<br>
All other marks mentioned may be trademarks or registered trademarks of their respective owners.
</div>
<!-- Footer -->
</div>
</td>
<td id="cell-3-3">&nbsp;</td>
<td id="cell-3-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-4-0" colspan="2">&nbsp;</td>
<td id="cell-4-1">&nbsp;</td>
<td id="cell-4-2" colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4458903-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>