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 > XMLBeans
Date Thu, 03 Sep 2009 19:32:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="http://cwiki.apache.org/confluence/display/CXF20DOC/XMLBeans">XMLBeans</a></h2>
    <h4>Page  <b>added</b> by             <a href="http://cwiki.apache.org/confluence/display/~dkulp">Daniel
Kulp</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <p><a href="http://xmlbeans.apache.org/" rel="nofollow">Apache XMLBeans</a>
is another technology for mapping XML Schema to java objects.   CXF added support for XMLBeans
in 2.1.   There are a two parts to the support for XMLBeans:</p>

<h3><a name="XMLBeans-CodeGeneration"></a>Code Generation</h3>

<p>The wsdl2java tool now allows a "-db xmlbeans" flag to be added that will generate
XMLBeans types for all the schema beans instead of the default JAXB beans.   With 2.1 and
2.2, the types are generated, but you still need to configure the XMLBeans databinding to
be used at runtime.   With 2.3, the generated code contains an @Databinding annotation marking
it as XMLBeans and the configuration is unnecessary. </p>


<h3><a name="XMLBeans-Runtime"></a>Runtime</h3>

<p>You need to configure the runtime to tell it to use XMLBeans for the databinding
instead of JAXB. </p>

<h4><a name="XMLBeans-Springconfig"></a>Spring config</h4>
<p>For the server side, your spring configuration would contain something like:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;jaxws:server serviceClass=<span class="code-quote">"demo.hw.server.HelloWorld"</span>
address=<span class="code-quote">"/hello_world"</span>&gt;</span>
    <span class="code-tag">&lt;jaxws:dataBinding&gt;</span>
       <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.xmlbeans.XmlBeansDataBinding"</span>
/&gt;</span>
    <span class="code-tag">&lt;/jaxws:dataBinding&gt;</span>
<span class="code-tag">&lt;/jaxws:server&gt;</span>
</pre>
</div></div>
<p>or</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;jaxws:endpoint
    id=<span class="code-quote">"helloWorld"</span>
    implementor=<span class="code-quote">"demo.spring.HelloWorldImpl"</span>
    address=<span class="code-quote">"http://localhost/HelloWorld"</span>&gt;
    <span class="code-tag">&lt;jaxws:dataBinding&gt;</span>
       <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.xmlbeans.XmlBeansDataBinding"</span>
/&gt;</span>
    <span class="code-tag">&lt;/jaxws:dataBinding&gt;</span>
<span class="code-tag">&lt;/jaxws:endpoint&gt;</span>
</pre>
</div></div>

<p>The client side is very similar:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;jaxws:client id=<span class="code-quote">"helloClient"</span>
                  serviceClass=<span class="code-quote">"demo.spring.HelloWorld"</span>
                  address=<span class="code-quote">"http://localhost:9002/HelloWorld"</span>&gt;
    <span class="code-tag">&lt;jaxws:dataBinding&gt;</span>
       <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.cxf.xmlbeans.XmlBeansDataBinding"</span>
/&gt;</span>
    <span class="code-tag">&lt;/jaxws:dataBinding&gt;</span>
<span class="code-tag">&lt;jaxws:client&gt;</span>
</pre>
</div></div>


<h4><a name="XMLBeans-FactoryBeans"></a>FactoryBeans</h4>

<p>If using programmatic factory beans instead of spring configuration, the databinding
can be set on the ClientProxyFactoryBean (and subclasses) and the ServerFactoryBean (and subclasses)
via:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
factory.getServiceFactory().setDataBinding(<span class="code-keyword">new</span>
org.apache.cxf.xmlbeans.XmlBeansDataBinding());
</pre>
</div></div>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>
       <a href="http://cwiki.apache.org/confluence/display/CXF20DOC/XMLBeans">View Online</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CXF20DOC/XMLBeans?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message