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, 11 Apr 2011 19:36: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/~muellerc">Christian
Mueller</a>
    </h4>
        <br/>
                         <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" >  {code}  <br>  features:addUrl
mvn:org.apache.camel.karaf/apache-camel/2.8-SNAPSHOT/xml/features <br></td></tr>
            <tr><td class="diff-changed-lines" >features:install <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">http</span>
<span class="diff-added-words"style="background-color: #dfd;">war</span> <br></td></tr>
            <tr><td class="diff-unchanged" >  features:install cxf <br>
 features:install camel-cxf <br></td></tr>
            <tr><td class="diff-snipped" >...<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>

<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-java">   
		&lt;?xml version=<span class="code-quote">"1.0"</span> encoding=<span
class="code-quote">"UTF-8"</span>?&gt;
		&lt;soap:Envelope xmlns:soap=<span class="code-quote">"http:<span class="code-comment">//schemas.xmlsoap.org/soap/envelope/"</span>&gt;
</span>			&lt;soap:Header /&gt;
			&lt;soap:Body&gt;
				&lt;ns2:inputReportIncident xmlns:ns2=<span class="code-quote">"http:<span
class="code-comment">//reportincident.example.camel.apache.org"</span>&gt;
</span>					&lt;incidentId&gt;111&lt;/incidentId&gt;
					&lt;incidentDate&gt;2011-03-05&lt;/incidentDate&gt;
					&lt;givenName&gt;Christian&lt;/givenName&gt;
					&lt;familyName&gt;Mueller&lt;/familyName&gt;
					&lt;summary&gt;Bla&lt;/summary&gt;
					&lt;details&gt;Bla bla&lt;/details&gt;
					&lt;email&gt;cmueller@apache.org&lt;/email&gt;
					&lt;phone&gt;0049 69 1234567&lt;/phone&gt;
				&lt;/ns2:inputReportIncident&gt;
			&lt;/soap:Body&gt;
		&lt;/soap:Envelope&gt;
  </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>
    </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=2&originalVersion=1">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