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 > How do I develop a service?
Date Wed, 31 Oct 2012 16:43: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/pages/viewpage.action?pageId=59841">How
do I develop a service?</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>
        Removed plug for simple front end.<br />
    </div>
        <br/>
                         <h4>Changes (2)</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" >Note that CXF generally restricts
WSDL support to WSI-BP, not the full WSDL 1.1 specification. <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">There
is also a [Simple Frontend] that allows you to create services without usage of Java annotations,
using XML configuration files instead. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h1. JAX-WS Providers <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >More Information: [Developing a JAX-WS
Service|Developing a Service] <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h1.
Simple Frontend <br> <br>Sometimes you don&#39;t want to annotate classes
or use the JAX-WS APIs. CXF includes a [Simple Frontend] which allows you to take nearly any
class and make a service out of it with absolutely no extra work. This is great for those
services which are simple or are quick prototypes. <br> <br>CXF uses the JAXB
databinding as the default, but you can use the [Aegis|Aegis (2.1)] data-binding for even
more simplicity. Whereas JAXB forces you to annotate your classes, Aegis works with no annotations
at all and also supports a wide variety of data-types out of the box, including things like
Maps and Sets. <br> <br>Services are publish via one of two means: <br>*
ServerFactoryBeans - these allow programmatic publishing of an endpoint <br>* CXF&#39;s
XML configuration format - i.e. &lt;simple:server ... /&gt; <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h1. Javascript <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        
<p>CXF provides you with many options to build services. This guide is meant to give
you a quick overview of those options and help you orient yourself quickly with CXF.</p>
<div>
<ul>
    <li><a href='#HowdoIdevelopaservice%3F-DifferentTypesOfServices'>Different
Types Of Services</a></li>
    <li><a href='#HowdoIdevelopaservice%3F-JAXWSAnnotatedServicesfromJava'>JAX-WS
Annotated Services from Java</a></li>
    <li><a href='#HowdoIdevelopaservice%3F-JAXWSAnnotatedServicesfromWSDL'>JAX-WS
Annotated Services from WSDL</a></li>
    <li><a href='#HowdoIdevelopaservice%3F-JAXWSProviders'>JAX-WS Providers</a></li>
    <li><a href='#HowdoIdevelopaservice%3F-Javascript'>Javascript</a></li>
</ul></div>

<h1><a name="HowdoIdevelopaservice%3F-DifferentTypesOfServices"></a>Different
Types Of Services</h1>

<p>CXF support three major types of services:</p>

<ul>
	<li>SOAP - this page summarizes the options for creating SOAP services.</li>
	<li>REST-ful - REST support is described <a href="/confluence/display/CXF20DOC/RESTful+Services"
title="RESTful Services">here</a>.</li>
	<li>CORBA</li>
</ul>


<h1><a name="HowdoIdevelopaservice%3F-JAXWSAnnotatedServicesfromJava"></a>JAX-WS
Annotated Services from Java</h1>

<p>The JAX-WS APIs include a set of <a href="https://jax-ws.dev.java.net/jax-ws-ea3/docs/annotations.html#1.%20Overview%7Coutline"
class="external-link" rel="nofollow">annotations</a> which allow you to build services
using annotated classes. These services are based on a single class which contains a set of
operations.</p>

<p>Here's a simple example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
@WebService
<span class="code-keyword">public</span> class Hello {
  <span class="code-keyword">public</span> <span class="code-object">String</span>
sayHi(<span class="code-object">String</span> name) {
    <span class="code-keyword">return</span> <span class="code-quote">"Hello
"</span> + name;
  }
}
</pre>
</div></div>
<p>JAX-WS includes many more annotations as well such as:</p>
<ul>
	<li>@WebMethod - allows you to customize the operation name, exclude the operation
from inclusion in the service, etc</li>
	<li>@WebParam - allows you to customize a parameter's name, namespace, direction (IN
or OUT), etc</li>
	<li>@WebResult - allows you to customize the return value of the web service call</li>
</ul>


<p>Data is marshalled from XML to Java and vice versa via the <a href="/confluence/display/CXF20DOC/JAXB"
title="JAXB">JAXB data-binding</a>.</p>

<p>Services are publish via one of two means:</p>
<ul>
	<li>The JAX-WS standard Endpoint APIs</li>
	<li>CXF's XML configuration format - i.e. &lt;jaxws:endpoint ... /&gt;</li>
</ul>


<p>More Information: <a href="/confluence/display/CXF20DOC/A+simple+JAX-WS+service"
title="A simple JAX-WS service">A simple JAX-WS service</a>, <a href="/confluence/display/CXF20DOC/Developing+a+Service"
title="Developing a Service">Developing a JAX-WS Service</a> (goes into much more
depth), <a href="/confluence/display/CXF20DOC/Writing+a+service+with+Spring" title="Writing
a service with Spring">Writing a service with Spring</a></p>

<h1><a name="HowdoIdevelopaservice%3F-JAXWSAnnotatedServicesfromWSDL"></a>JAX-WS
Annotated Services from WSDL</h1>

<p>If you have existing WSDLs for your service or wish to write your WSDL first and
then generate classes, CXF has many tools to help you do this.</p>

<p>The WSDL2Java tool will generate a JAX-WS annotated service and server stub from
your WSDL. You can run it one of three ways:</p>
<ul>
	<li><a href="/confluence/display/CXF20DOC/WSDL+to+Java" title="WSDL to Java">The
command line</a></li>
	<li><a href="/confluence/display/CXF20DOC/Using+CXF+with+maven#UsingCXFwithmaven-MavenPlugin">The
Maven Plugin</a></li>
	<li>With the WSDL2Java API</li>
</ul>


<p>Note that CXF generally restricts WSDL support to WSI-BP, not the full WSDL 1.1 specification.</p>

<p>There is also a <a href="/confluence/display/CXF20DOC/Simple+Frontend" title="Simple
Frontend">Simple Frontend</a> that allows you to create services without usage of
Java annotations, using XML configuration files instead.</p>

<h1><a name="HowdoIdevelopaservice%3F-JAXWSProviders"></a>JAX-WS Providers</h1>

<p>JAX-WS Providers allow you to create services which work at the message level - as
opposed to the operation level as with annotated classes. The have a single operation "invoke"
which receives either the message payload (i.e. the SOAP Body) or the whole message itself
(i.e. the SOAP Envelope).</p>

<p>Here's a simple example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
@WebServiceProvider
<span class="code-keyword">public</span> class HelloProvider {
  <span class="code-keyword">public</span> Source invoke(Source request) {
    <span class="code-keyword">return</span> ....;
  }
}
</pre>
</div></div>
<p>Services are publish via one of two means:</p>
<ul>
	<li>The JAX-WS standard Endpoint APIs</li>
	<li>CXF's XML configuration format - i.e. &lt;jaxws:endpoint ... /&gt;</li>
</ul>


<p>More Information: <a href="/confluence/display/CXF20DOC/Developing+a+Service"
title="Developing a Service">Developing a JAX-WS Service</a></p>

<h1><a name="HowdoIdevelopaservice%3F-Javascript"></a>Javascript</h1>

<p>CXF provides a Javascript module which allows you to build services in Javascript
with the Java Rhino library. One advantage of this is that you can use E4X to interact more
easily with the XML. For more information see the <a href="/confluence/display/CXF20DOC/JavaScript"
title="JavaScript">JavaScript</a> page.</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/pages/viewpage.action?pageId=59841">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=59841&revisedVersion=17&originalVersion=16">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=59841&showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message