cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache CXF Documentation > CXF_Eclipse_Plugin_Instructions
Date Mon, 31 Jan 2011 21:52:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/2036/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
<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="">CXF_Eclipse_Plugin_Instructions</a></h2>
    <h4>Page <b>edited</b> by             <a href="">Daniel
                         <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" > <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Once your WSDL is set, use it
to create your implementation class.  Highlight the WSDL and right-click.  Select _JAX-WS
Tools/Generate Code_.  Select _Implementation_ and, if you&#39;re using *Ant*, select
_Generate Ant Script_.  If the _Impl_ file isn&#39;t created, you can run _wsdl2java_
using the [command line, Ant task or <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">maven|].</span>
<span class="diff-added-words"style="background-color: #dfd;">maven|WSDL to Java].</span>
            <tr><td class="diff-unchanged" > <br>{noformat} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="CXF_Eclipse_Plugin_Instructions-WebServiceswithCXFandEclipse"></a>Web
Services with CXF and Eclipse</h1>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Watch Out!</b><br
/>This page is out of date, and there is a new approach to developing CXF services with
Eclipse! We'll have the details up here as soon as possible.</td></tr></table></div>

<h2><a name="CXF_Eclipse_Plugin_Instructions-Introduction"></a>Introduction</h2>

<p>These directions assume that you are familiar with <a href=""
class="external-link" rel="nofollow">using Eclipse</a>, that you know how to <a
href="" class="external-link" rel="nofollow">create
a war file</a> and that you know <a href=""
class="external-link" rel="nofollow">how to create a WSDL</a>.</p>

<h2><a name="CXF_Eclipse_Plugin_Instructions-Setup"></a>Setup</h2>

<p>It is assumed that you have already downloaded and installed <a href=""
class="external-link" rel="nofollow">Eclipse</a> with version 3.3 or higher.  You
will also need to download and extract the <a href=""
class="external-link" rel="nofollow">Apache CXF binary distribution</a> and <a
href="" class="external-link" rel="nofollow">Apache
Tomcat</a> or your favorite web application server.</p>

<h3><a name="CXF_Eclipse_Plugin_Instructions-UpdatingEclipse"></a>Updating

<p>You will need to install some extra plugins in eclipse for the Web Services in general,
and the CXF Web Services specifically. You can easily download the <a href=""
class="external-link" rel="nofollow">all-in-one package</a> and extract it to your
eclipse folder.<br/>
Note: The downloaded package is not the latest version. The latest version of STP(SOA Tools
Platform) plugin which integrates the new <a href="/confluence/display/CXF20DOC/Java+to+WS"
title="Java to WS">java2ws tool</a> can only support CXF 2.1.* or higher.</p>

<h3><a name="CXF_Eclipse_Plugin_Instructions-AddingCXFruntimeinEclipse"></a>Adding
CXF runtime in Eclipse</h3>

<p>Once you have all your uploads loaded, you'll need to link CXF as your <em>Installed
runtime</em>.  Click <em>Windows/Preferences/SOA Tools/Installed Runtimes</em>
to open an runtime configuration page. In this page click <em>Add</em> button
and browse to your directory that contains Apache CXF, then click <em>OK</em>.</p>

<h3><a name="CXF_Eclipse_Plugin_Instructions-AddingTomcatServerinEclipse"></a>Adding
Tomcat Server in Eclipse</h3>
	<li>Click <em>Window/Show View/Other.../Server/Servers</em> to open the
server view.</li>
	<li>In the server view, right click and select <em>New/Server/Apache/Tomcat v6.0
Server</em>. Click <em>next</em> button and browse to your directory that
contains Tomcat, then click <em>Finish</em>.</li>
	<li>Now, in the server view, there will be a new tomcat server. Double click the tomcat
server to open the configuration page in <b>Editor Part</b>.</li>
	<li>In the <b>Server Locatiotn</b> part of this configuration page, choose
<b>Use Tomcat installation (takes control of Tomcat installation)</b> and modify
the <b>Deploy path</b> from wtpwebapps to webapps.</li>
	<li>There should be an project named <b>Servers</b> in <b>Navigator
View</b>. Open the file <b></b> of this project and add
<em>(CXF_Install_Location)/lib/*.jar</em> to the property <em>shared.loader</em>.</li>
	<li>All finished!</li>

<h2><a name="CXF_Eclipse_Plugin_Instructions-CreatingaProject"></a>Creating
a Project</h2>

<h3><a name="CXF_Eclipse_Plugin_Instructions-JavaFirst%28NotRecommended%29"></a>Java
First (Not Recommended)</h3>

<p><b>NOTE:</b> Keep the default directory structure.  The automated system
gets confused if you change it.</p>

	<li>Select File/New/Other/SOA Tools/JAX-WS Java First Project</li>
	<li>Say yes when asked if you want to open the JAX-WS perspective</li>
	<li>Create an interface for your service:
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>package com.cid.simpleservice.service

public interface ScientificCalculator {
   public float squareRoot( float value,float pow);

	<li>Annotate the interface:
		<li>Right-click class in the <em>Outline View</em></li>
		<li>Select <b>JAX-WS Tools/Create Web Service</b></li>
		<li>Right-click your method(s) name(s) in the <em>Outline View</em></li>
		<li>Select <b>JAX-WS Tools/Create Web Method</b></li>
	<li>Save your file. If the <em>Project/Build Automatically</em> has been
checked, you should see a new <em>wsdl</em> folder show up in your project directory
structure as soon as you save it. Or you can also build your project manually to generate
<em>wsdl</em> folder. Within the folder should be a WSDL based upon your interface.</li>

<p>Now you'll need to make some modifications to the automatically generated comments.
	<li>Click on <em>@WebService</em>, which should be appearing above your
interface name.  The <em>Annotation Properties</em> should appear<br/>
in the box below your editing window.  If not, select Window/Show View/Other.  From the pop-up
menu, select SOA Tools/@ Annotation Properties.</li>
	<li>In the Annotation Properties, change javax.jws.soap.SOAPBinding from false to true.
 This may require you to change other settings.  If so, check the CXF documentation for correct

<p>After your changes are made and save without any error, a WSDL should appear in the
wsdl folder.  If it doesn't, use <b>java2wsdl</b> from the CXF package.  You can
either run it from the <a href="/confluence/display/CXF20DOC/Java+to+WSDL" title="Java
to WSDL">command prompt, as an ant task</a>, or <a href="/confluence/display/CXF20DOC/Using+CXF+with+maven"
title="Using CXF with maven">from Maven</a>.  The<br/>
default output directory will be the <em>wsdl</em> directory.</p>

<p>After the WSDL is created, modify to meet your needs.  For example, the port is,
by default <a href="http://localhost:9090/" class="external-link" rel="nofollow">http://localhost:9090/</a>.
 In addition, leaving the parameter named <em>parameters</em> on the input request
is not acceptable to .NET code creation routines.  </p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;wsdl:definitions name="ScientificCalculatorService" targetNamespace=""

xmlns:ns1="" xmlns:wsdl=""

xmlns:xsd="" xmlns:soap=""&gt;
&lt;xsd:schema xmlns:xsd="" xmlns=""

attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace=""&gt;
&lt;xsd:element name="squareRoot" type="squareRoot"/&gt;
&lt;xsd:complexType name="squareRoot"&gt;
&lt;xsd:element name="arg0" type="xsd:float"/&gt;
&lt;xsd:element name="arg1" type="xsd:float"/&gt;
&lt;xsd:element name="squareRootResponse" type="squareRootResponse"/&gt;
&lt;xsd:complexType name="squareRootResponse"&gt;
&lt;xsd:element name="return" type="xsd:float"/&gt;
  &lt;wsdl:message name="squareRootResponse"&gt;
    &lt;wsdl:part name="squareRootOutput" element="ns1:squareRootResponse"&gt;
  &lt;wsdl:message name="squareRoot"&gt;
    &lt;wsdl:part name="squareRootInput" element="ns1:squareRoot"&gt;
  &lt;wsdl:portType name="ScientificCalculator"&gt;
    &lt;wsdl:operation name="squareRoot"&gt;
      &lt;wsdl:input name="squareRoot" message="ns1:squareRoot"&gt;
      &lt;wsdl:output name="squareRootResponse" message="ns1:squareRootResponse"&gt;
  &lt;wsdl:binding name="ScientificCalculatorServiceSoapBinding" type="ns1:ScientificCalculator"&gt;
    &lt;soap:binding style="document" transport=""/&gt;
    &lt;wsdl:operation name="squareRoot"&gt;
      &lt;soap:operation soapAction="" style="document"/&gt;
      &lt;wsdl:input name="squareRoot"&gt;
        &lt;soap:body use="literal"/&gt;
      &lt;wsdl:output name="squareRootResponse"&gt;
        &lt;soap:body use="literal"/&gt;
  &lt;wsdl:service name="ScientificCalculatorService"&gt;
    &lt;wsdl:port name="ScientificCalculatorPort" binding="ns1:ScientificCalculatorServiceSoapBinding"&gt;
      &lt;soap:address location="http://localhost:8080/JavaFirstTest"/&gt;


<p>Once your WSDL is set, use it to create your implementation class.  Highlight the
WSDL and right-click.  Select <em>JAX-WS Tools/Generate Code</em>.  Select <em>Implementation</em>
and, if you're using <b>Ant</b>, select <em>Generate Ant Script</em>.
 If the <em>Impl</em> file isn't created, you can run <em>wsdl2java</em>
using the <a href="/confluence/display/CXF20DOC/WSDL+to+Java" title="WSDL to Java">command
line, Ant task or maven</a>.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
 * Please modify this class to meet your needs
 * This class is not complete

package com.cid.simpleservice.service;

import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebResult;

@javax.jws.WebService(name = "ScientificCalculator", serviceName = "ScientificCalculatorService",
                      portName = "ScientificCalculatorPort",
                      targetNamespace = "", 
                      wsdlLocation = "file:wsdl/javaFirstTest.wsdl" ,
		      endpointInterface = "com.cid.simpleservice.service.ScientificCalculator")
public class ScientificCalculatorImpl implements ScientificCalculator {

    private static final Logger LOG = Logger.getLogger(ScientificCalculatorImpl.class.getName());

    /* (non-Javadoc)
     * @see com.cid.simpleservice.service.ScientificCalculator#squareRoot(float  arg0 ,)float
 arg1 )*
    public float squareRoot(float arg0,float arg1) {"Executing operation squareRoot");
        try {
            float _return = 0.0f;
            return _return;
        } catch (Exception ex) {
            throw new RuntimeException(ex);



<p><b>Note:</b> this last step is why it's suggested that you not use this
process.  Using java2wsdl, then wsdl2java is not supported at this time by CXF.  And, as you've
seen some of the automation doesn't work quite right.</p>

<p>Modify your Implementation class to reflect your actual methods.</p>

<h3><a name="CXF_Eclipse_Plugin_Instructions-WSDLFirst"></a>WSDL First</h3>

<p>Create your WSDL.  The syntax is beyond the scope of this wiki.  But there is a tool
within Eclipse for creating one. Just select File/New/Other/Web Services/WSDL.  You can validate
your WSDL by using <em>wsdl2java</em> with the <em>-validate</em>

<p>Create a new project: File/New/Project/SOA Tools/JAX-WS WSDL First Project.  Select
your WSDL.  Select to create the Implementation and, if you wish, Generate Ant Script.  Leave
everything checked as shown.  If the code isn't automatically generated, run <em>wsdl2java</em>
to generate your code.</p>

<p>Modify your implementation classes to reflect your actual methods.</p>

<h2><a name="CXF_Eclipse_Plugin_Instructions-DeployingProject"></a>Deploying
<h3><a name="CXF_Eclipse_Plugin_Instructions-BuildingPackage"></a>Building
<p>Right click the WSDL file and select <em>Build Package...</em> in popup
menu. Then an war file will be generated in the folder <em>build</em>.</p>
<h3><a name="CXF_Eclipse_Plugin_Instructions-DeployingPackage"></a>Deploying
<p>Right click the WSDL file or the war file and select <em>Deploy...</em>
in popup menu. In the popup window, select Tomcat Server you just created above. Then click
<h3><a name="CXF_Eclipse_Plugin_Instructions-StartingService"></a>Starting
<p>Start the Tomcat Server in the Server View. If everything is OK, the service of your
project should be activated. <br/>
Once you deploy your war file, go to: http://&lt;your server&gt;:&lt;port&gt;/&lt;deployment
name&gt;/services.  You'll see a link to your wsdl file.  Click on it and your wsdl should
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
        <a href="">View
        <a href="">View
        <a href=";showCommentArea=true#addcomment">Add

View raw message