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 > Embedding CXF inside Spring
Date Fri, 16 Oct 2009 12:12: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/Embedding+CXF+inside+Spring">Embedding
CXF inside Spring</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~mazzag">Glen
Mazza</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <p>You can embed CXF within an existing Spring application. Since all XML configuration
files are Spring xml files, the two approaches should be equivalent. </p>

<p>CXF includes Spring configuration files which configure the various CXF modules.
You will want to import these into your application. Here is an example that imports the core
CXF components, the SOAP binding, and the servlet transport:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
	<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
	<span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd"&gt;

	<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf.xml"</span>
/&gt;</span>
	<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf-extension-soap.xml"</span>
/&gt;</span>
	<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf-servlet.xml"</span>
/&gt;</span>
  ...
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<p>To include all the CXF modules you can use cxf-all or a wildcard expression:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
	<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
	<span class="code-keyword">xmlns:jaxws</span>=<span class="code-quote">"http://cxf.apache.org/jaxws"</span>
	xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd"&gt;

	<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath:META-INF/cxf/cxf.xml"</span>
/&gt;</span>
	<span class="code-tag">&lt;import resource=<span class="code-quote">"classpath*:META-INF/cxf/cxf-extension-*.xml"</span>
/&gt;</span>
  ...
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<p>The only module cxf-all won't include is the servlet transport. If you want to include
the servlet transport you must specify it specifically. This is because it will tell CXF to
no longer use the standalone HTTP transport which is specified in the "classpath:META-INF/cxf/cxf-extension-http-jetty.xml"
xml file, and you may not always want to do this.</p>

<p><a href="http://www.nabble.com/Need-clarification-on-cxf-servlet.xml-config-file.-td19598828.html#a19602024"
rel="nofollow">This thread</a> provides more information on CXF Spring files that
may need to be imported in your web.xml.</p>
     </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/Embedding+CXF+inside+Spring">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=62417&revisedVersion=5&originalVersion=4">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CXF20DOC/Embedding+CXF+inside+Spring?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message