camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > How can I get the remote connection IP address from the camel-cxf consumer ?
Date Mon, 27 Dec 2010 02:49:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/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/pages/viewpage.action?pageId=24191579">How
can I get the remote connection IP address from the camel-cxf consumer ?</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~njiang">willem
jiang</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h2><a name="HowcanIgettheremoteconnectionIPaddressfromthecamel-cxfconsumer%3F-HowcanIgettheremoteconnectionIPaddressfromthecamelcxfconsumer%3F"></a>How
can I get the remote connection IP address from the camel-cxf consumer ?</h2>
<p>From Camel 2.6.0, you can access the CXF Message by using the key of <tt>CamelCxfMessage</tt>
from message header, and you can get the ServletRequest instance from the CXF message, then
you can get the remote connection IP easily.<br/>
Here is the code snippet.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
 <span class="code-comment">// check the remote IP from the CXF Message
</span> org.apache.cxf.message.Message cxfMessage = exchange.getIn().getHeader(CxfConstants.CAMEL_CXF_MESSAGE,
org.apache.cxf.message.Message.class);
 ServletRequest request = (ServletRequest)cxfMessage.get(<span class="code-quote">"HTTP.REQUEST"</span>);
 <span class="code-object">String</span> remoteAddress = equest.getRemoteAddr();
</pre>
</div></div>
    </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/pages/viewpage.action?pageId=24191579">View
Online</a>
              |
       <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=24191579&showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message