camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <>
Subject Extracting request IP in Camel CXF
Date Thu, 16 Dec 2010 16:07:12 GMT


When I used a standalone CXF web service, I used to be able to extract the
remote IP address in my Impl class. CXF would inject a WebServiceContext
object in my Impl class and I would have the class as follows:

public class MyWSImpl implements IMyWS {
	private WebServiceContext context;
        public String foo( String message ) {
                        ( (HttpServletRequest) context.getMessageContext()
                        .get(AbstractHTTPDestination.HTTP_REQUEST) )
              return "true";

However, now I have made my web service a part of the an architecture where
the web service is simply an endpoint in Camel. Now Camel starts my web
service for me by virtue of making the WS endpoint be a part of a camel
route. As a result, I don't have my Impl class anymore.

The cxf web service endpoint in Camel is as follows:

	<cxf:cxfEndpoint id="myWsEndpoint" 
					 xmlns:e="" >

And then this endpoint is a part of the camel route as follows:

		<camel:route id="WsXmlMessagesRoute">
			<camel:from uri="cxf:bean:myWsEndpoint" />
			<camel:process ref="testProcessor"/>
			<camel:inOnly uri="file:data/inbox" />

A request comes into my web service endpoint, gets forwarded to a Processor
and then gets written out to a file. The processor is a simple Java file
that has the following method:

public void process(Exchange exchange)

I would like to be able to extract the IP address of whoever invoked my web
service in this processor.

It seems that the IP address has to be hidden somewhere in the "exchange"
object that comes into the process method. I have spent multiple hours
trying to figure out how to extract the IP address, but have been

I looked for a solution on this forum, but couldn't find anything here

Can anyone please guide me? Any help will be greatly appreciated.


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message