camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashwin Karpe <aka...@fusesource.com>
Subject Re: Extracting request IP in Camel CXF
Date Thu, 23 Dec 2010 03:28:52 GMT

Hi,

If the IP address is in a SOAP Header, can you please try the following

1. Add a HeaderFilterStrategy bean in camel-context.xml as shown below

<bean id="foobar"
class="org.apache.camel.component.cxf.CxfHeaderFilterStrategy">
    <property name="relayAllMessageHeaders" value="true"/>
</bean>

2. Add this id to your camel-cxf endpoint as shown below

	<camel:route id="wsXmlMessagesRoute">
			<camel:from uri="cxf:bean:wsEndpoint?headerFilterStrategy=#foobar" />
			<camel:process ref="testProcessor"/>
			<camel:inOnly uri="file://test_files" />
		</camel:route>	

You might want to check out the section "Changes since Release 2.0" in the
documentation  http://camel.apache.org/cxf.html
http://camel.apache.org/cxf.html  It covers in-band and out-of-band headers
and how they are propagated in camel-cxf.

BTW, I checked out the code in 2.5.0 and it should be passing along the
headers. I suspect based on the fact that the MessageContentList Header
entry is an empty list that CXF is for some reason not passing headers
along. 

I am not sure if the IP address is passed in the HTTP headers and not SOAP
Headers. If so, the way to get at an IP address embedded in HTTP headers
surrounding the SOAP Headers, however this involves instantiating a CXF bus
object, adding an in-interceptor in the PRE_STREAM phase to get at the
header before it is stripped by CXF and injecting the bus object into the
camel-cxf consumer endpoint as shown below.

<camel:from uri="cxf:bean:wsEndpoint?&bus=#myCustomBus" /> 

If what you are looking to accomplish is to allow/disallow requests based on
IP address, the interceptor should do the trick. Just throw a remote
exception in the interceptor if the address does not match. Else you can add
a IP address as a new header to the SOAP Message Header in the interceptors
and then you should see the header in the processor.

For more details on creating CXF interceptors check out
http://cxf.apache.org/docs/interceptors.html
http://cxf.apache.org/docs/interceptors.html 

Phew.... Rather long answer. Hope this helps.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com
http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
-- 
View this message in context: http://camel.465427.n5.nabble.com/Extracting-request-IP-in-Camel-CXF-tp3308148p3315985.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message