camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > CXF Example OSGi
Date Mon, 27 Jun 2011 07:54:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&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/display/CAMEL/CXF+Example+OSGi">CXF
Example OSGi</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (3)</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" >*Available as of Camel 2.8* <br>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{info:title=Spring-DM
vs. OSGi Blueprint} <br>This example uses Spring DM for OSGi. There is another [CXF
Example OSGi Blueprint] that uses Blueprint.  <br>{info} <br> <br>The example
is in the {{examples/camel-example-cxf-osgi}} directory. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >A simple example which receives web
service calls (via a CXF consumer, using bean binding) and write these requests into the file
system. It&#39;s not a very useful use case, but the goal of this example is to show you
how you can use the CXF consumer component in an OSGI environment with the OSGI HTTP service.
If your target container is Apache Karaf or Apache ServiceMix, you can use PAX Web to setup
and start an OSGI HTTP service. All your Camel bundles using a Camel CXF consumer can use
this HTTP service and do not have to start it&#39;s own Jetty instance. Another possibility
you get is, that all your provided services can share the same port. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >  ex : <br>  --&gt; and
the message formatted that you copy in SOAPUI <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words">{code<span
class="diff-added-chars"style="background-color: #dfd;">:xml</span>}</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >		&lt;?xml version=&quot;1.0&quot;
encoding=&quot;UTF-8&quot;?&gt; <br>		&lt;soap:Envelope xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > 6) Check the file system <br>
Check the folder &quot;target/inbox/&quot; in your file system that a message has
been arrived. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
<br>h3. See Also <br>- [CXF Example OSGi Blueprint] <br>- [Examples] <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="CXFExampleOSGi-CXFExampleOSGi"></a>CXF Example OSGi</h2>
<p><b>Available as of Camel 2.8</b></p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Spring-DM
vs. OSGi Blueprint</b><br />This example uses Spring DM for OSGi. There is another
<a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=CXF+Example+OSGi+Blueprint&amp;linkCreation=true&amp;fromPageId=26117871"
class="createlink">CXF Example OSGi Blueprint</a> that uses Blueprint.</td></tr></table></div>

<p>The example is in the <tt>examples/camel-example-cxf-osgi</tt> directory.</p>

<p>A simple example which receives web service calls (via a CXF consumer, using bean
binding) and write these requests into the file system. It's not a very useful use case, but
the goal of this example is to show you how you can use the CXF consumer component in an OSGI
environment with the OSGI HTTP service. If your target container is Apache Karaf or Apache
ServiceMix, you can use PAX Web to setup and start an OSGI HTTP service. All your Camel bundles
using a Camel CXF consumer can use this HTTP service and do not have to start it's own Jetty
instance. Another possibility you get is, that all your provided services can share the same
port.</p>

<p>This example is located in the <tt>examples/camel-example-cxf-osgi</tt>
directory of the Camel distribution.<br/>
There is a <tt>README.txt</tt> file with instructions how to run it.</p>

<p>You will need to compile this example first:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  mvn install
</pre>
</div></div>

<p>Remarks:</p>
<ul class="alternate" type="square">
	<li>During the compilation phase, a unit test will be performed, this unit test simulates
the<br/>
  communication between a client calling the web service exposed by our camel/cxf route.</li>
	<li>In Eclipse, I have used the following option when starting the junit test case.
This option tells<br/>
  CXF that it must use log4j : -Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger</li>
</ul>


<p>To run the example on Apache ServiceMix 4.x or Apache Karaf 1.x / 2.x</p>

<p>  1) launch the server</p>
  <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  karaf.bat
  </pre>
</div></div>

<p>  For Karaf 2.0 : edit the file jre.properties to add the following packages to be
exported</p>
  <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  jre-1.6=, \
 com.sun.org.apache.xerces.internal.dom, \
 com.sun.org.apache.xerces.internal.jaxp, \
  </pre>
</div></div>

<p>  2) Add features required</p>
  <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"> 
  features:addUrl mvn:org.apache.camel.karaf/apache-camel/2.8-SNAPSHOT/xml/features
  features:install war
  features:install cxf
  features:install camel-cxf
  </pre>
</div></div>

<p>  3) Deploy the example bundle</p>
  <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  osgi:install -s mvn:org.apache.camel/camel-example-cxf-osgi
  </pre>
</div></div>

<p>  4) Verify that your service is available using in the browser the following url.
We assume you<br/>
  use the default PAX Web configuration which use the port 8181 for http. If you would like
to use<br/>
  another port or https, change the configuration in KARAF_HOME/etc/org.ops4j.pax.web.cfg.
Please<br/>
  see <a href="http://wiki.ops4j.org/display/paxweb/Pax+Web" class="external-link" rel="nofollow">http://wiki.ops4j.org/display/paxweb/Pax+Web</a>
for more information.</p>
  <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
  http:<span class="code-comment">//localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident?wsdl
</span>  </pre>
</div></div>

<p>  5) Start SOAPUI <br/>
  Create a new project called camel-example-cxf-osgi<br/>
  Point to the following url : <a href="http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident?wsdl"
class="external-link" rel="nofollow">http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident?wsdl</a><br/>
  Open the request 1 (under camel-example-cxf-osgi --&gt; ReportIncidentBinding --&gt;
ReportIncident) and copy/paste the SOAP<br/>
  message generated by the unit test</p>

<p>  ex :<br/>
  --&gt; and the message formatted that you copy in SOAPUI</p>
  <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">   
		<span class="code-tag">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;</span>
		<span class="code-tag">&lt;soap:Envelope <span class="code-keyword">xmlns:soap</span>=<span
class="code-quote">"http://schemas.xmlsoap.org/soap/envelope/"</span>&gt;</span>
			<span class="code-tag">&lt;soap:Header /&gt;</span>
			<span class="code-tag">&lt;soap:Body&gt;</span>
				<span class="code-tag">&lt;ns2:inputReportIncident <span class="code-keyword">xmlns:ns2</span>=<span
class="code-quote">"http://reportincident.example.camel.apache.org"</span>&gt;</span>
					<span class="code-tag">&lt;incidentId&gt;</span>111<span class="code-tag">&lt;/incidentId&gt;</span>
					<span class="code-tag">&lt;incidentDate&gt;</span>2011-03-05<span
class="code-tag">&lt;/incidentDate&gt;</span>
					<span class="code-tag">&lt;givenName&gt;</span>Christian<span
class="code-tag">&lt;/givenName&gt;</span>
					<span class="code-tag">&lt;familyName&gt;</span>Mueller<span class="code-tag">&lt;/familyName&gt;</span>
					<span class="code-tag">&lt;summary&gt;</span>Bla<span class="code-tag">&lt;/summary&gt;</span>
					<span class="code-tag">&lt;details&gt;</span>Bla bla<span class="code-tag">&lt;/details&gt;</span>
					<span class="code-tag">&lt;email&gt;</span>cmueller@apache.org<span
class="code-tag">&lt;/email&gt;</span>
					<span class="code-tag">&lt;phone&gt;</span>0049 69 1234567<span
class="code-tag">&lt;/phone&gt;</span>
				<span class="code-tag">&lt;/ns2:inputReportIncident&gt;</span>
			<span class="code-tag">&lt;/soap:Body&gt;</span>
		<span class="code-tag">&lt;/soap:Envelope&gt;</span>
  </pre>
</div></div>  

<p> 6) Check the file system<br/>
 Check the folder "target/inbox/" in your file system that a message has been arrived.</p>

<h3><a name="CXFExampleOSGi-SeeAlso"></a>See Also</h3>
<ul class="alternate" type="square">
	<li><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=CXF+Example+OSGi+Blueprint&amp;linkCreation=true&amp;fromPageId=26117871"
class="createlink">CXF Example OSGi Blueprint</a></li>
	<li><a href="/confluence/display/CAMEL/Examples" title="Examples">Examples</a></li>
</ul>

    </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/display/CAMEL/CXF+Example+OSGi">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=26117871&revisedVersion=3&originalVersion=2">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/CXF+Example+OSGi?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message