camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Camel > CXF Proxy Example
Date Sun, 26 Sep 2010 10:20:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
<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="">CXF
Proxy Example</a></h2>
    <h4>Page  <b>added</b> by             <a href="">Claus
    <div class="notificationGreySide">
         <h2><a name="CXFProxyExample-CXFProxyExample"></a>CXF Proxy Example</h2>
<p><b>Available as of Camel 2.5</b></p>

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

<p>If you use maven then you can easily run it from the command line using:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mvn jetty:run

<h3><a name="CXFProxyExample-About"></a>About</h3>

<p>This example demonstrates how you can use <a href="/confluence/display/CAMEL/CXF"
title="CXF">CXF</a> to proxy a real web service. For example in this case we want
Camel to validate and enrich the input message before its send to the real web service. We
do this to ensure the data is correct and that missing information is added automatic by Camel.
In real life you may want to do this in case a client send bad/faulty data to a web service,
and its costly/not possible to update and fix that client. Instead lets fix it by a proxy
with Camel.</p>

<h3><a name="CXFProxyExample-Implementation"></a>Implementation</h3>

<p>Since this is a example it provides both the Camel application and the real web service
in the same JVM. In your use-case the real webs ervice will be hosted on another server etc.</p>

<h4><a name="CXFProxyExample-SpringXML"></a>Spring XML</h4>

<p>In the Spring XML file we have define the <a href="/confluence/display/CAMEL/CXF"
title="CXF">CXF</a> proxy endpoint using the <tt>&lt;cxf:cxfEndpoint&gt;</tt>
And the real web service is the Spring bean with the id <tt>realWebService</tt>.</p>

<p>As you can see in the Camel route we use a <a href="/confluence/display/CAMEL/CXF"
title="CXF">CXF</a> consumer to proxy the web service. Then we route the message
to the enrich bean which validates and add the missing information. Then we just use the <a
href="/confluence/display/CAMEL/HTTP" title="HTTP">HTTP</a> component to send the
web service request to the real web service.<br/>
The reply from the real web service is then logged and use as reply for the proxied web service
as well.</p>

<p>TODO: e1</p>

<h4><a name="CXFProxyExample-Enrichbean"></a>Enrich bean</h4>

<p>The enrich bean is Java code which in our simple example will just set the incidentId
parameter to the fixed value of 456. In your implementation you can of course do a lot more.</p>

<p>TODO: e1</p>

<h3><a name="CXFProxyExample-Runningtheexample"></a>Running the example</h3>

<p>You start the example from the command line using the maven goal <tt>mvn jetty:run</tt>.
There is also a <tt>build.xml</tt> file for ANT users.<br/>
You can also start the Camel application from your IDE, by running the <tt>org.apache.camel.example.cxf.proxy.MyMain</tt>
main class.</p>

<p>You can then use SoapUI or another web service client and send a request to the <tt><a
href="http://localhost:9080/camel-example-cxf-proxy/webservices/incident" class="external-link"
url. The wsdl is located at: <tt><a href="http://localhost:9080/camel-example-cxf-proxy/webservices/incident?wsdl"
class="external-link" rel="nofollow">http://localhost:9080/camel-example-cxf-proxy/webservices/incident?wsdl</a></tt>.</p>

<p>The console should then output progress.</p>

<h3><a name="CXFProxyExample-Sampleoutput"></a>Sample output</h3>

<p>Here is some sample output from the console:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
2010-09-26 12:20:46,974 [main           ] INFO  DefaultCamelContext            - Apache Camel
2.5-SNAPSHOT (CamelContext: camel-1) started in 0.858 seconds
2010-09-26 12:20:55,685 [tp-1790017034-1] INFO  input                          - Exchange[ExchangePattern:InOut,
BodyType:<span class="code-keyword">null</span>, Body:&lt;soapenv:Envelope
xmlns:soapenv=<span class="code-quote">"http:<span class="code-comment">//"</span>
xmlns:rep=<span class="code-quote">""</span>&gt;
</span>   &lt;soapenv:Header/&gt;
         &lt;summary&gt;Bla bla&lt;/summary&gt;
         &lt;details&gt;More bla&lt;/details&gt;
Incident was , changed to 456

Invoked real web service: id=456 by Ibsen Claus

2010-09-26 12:20:55,997 [tp-1790017034-1] INFO  output                         - Exchange[ExchangePattern:InOut,, Body:
&lt;soap:Envelope xmlns:soap=<span class="code-quote">"http:<span class="code-comment">//"</span>&gt;
</span>    &lt;soap:Body&gt;
        &lt;ns2:outputReportIncident xmlns:ns2=<span class="code-quote">"http:<span
</span>            &lt;code&gt;OK;456&lt;/code&gt;

<h3><a name="CXFProxyExample-SeeAlso"></a>See Also</h3>
<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Examples" title="Examples">Examples</a></li>

    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message