You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Robert Gombotz <ro...@gmail.com> on 2005/04/26 23:03:36 UTC

obtaining consumer IP

Hi!


I would need to obtain the IP address of clients/consumers that make
calls to my Web services, preferably using a SOAP handler.
So far, I have not found a way of achieving this. The MessageContext
seems to be the only data I have in a handler, and from what I
understand it does not contain the client's IP.

Any hints and ideas are greatly appreciated.


Rob

Re: obtaining consumer IP

Posted by Robert Gombotz <ro...@gmail.com>.
Great!

Thanks for your advice as well. What I am doing now is purely
academic, so it doesn't have to pass the "real-world" test :-)

Rob


On 4/26/05, Tim K. (Gmane) <tk...@ugcs.net> wrote:
> From the MessageContext you can get the HttpServletRequest and from
> that the IP:
> 
> HttpServletRequest req = (HttpServletRequest)
> msgContext.getProperty(org.apache.axis.transport.http.HTTPConstants.MC_HTTP_SERVLETREQUEST);
> 
> String ip = req.getRemoteAddr();
> 
> However, keep in mind that the IP address may be misleading if the
> client is going through a proxy or you have a load balancer in front of
> your server or a caching server, etc. I know in a real production system
> you will most likely get a local IP address.  Also, if you want to do
> security based on the IP address, keep in mind that IP addresses can be
> easily spoofed. For this reason I find relying on the IP address to be a
> bad plan.
> 
> Tim
> 
> 
> Robert Gombotz wrote:
> 
> >Hi!
> >
> >
> >I would need to obtain the IP address of clients/consumers that make
> >calls to my Web services, preferably using a SOAP handler.
> >So far, I have not found a way of achieving this. The MessageContext
> >seems to be the only data I have in a handler, and from what I
> >understand it does not contain the client's IP.
> >
> >Any hints and ideas are greatly appreciated.
> >
> >
> >Rob
> >
> >
> >
> 
>

Re: obtaining consumer IP

Posted by "Tim K. (Gmane)" <tk...@ugcs.net>.
 From the MessageContext you can get the HttpServletRequest and from 
that the IP:

HttpServletRequest req = (HttpServletRequest) 
msgContext.getProperty(org.apache.axis.transport.http.HTTPConstants.MC_HTTP_SERVLETREQUEST);

String ip = req.getRemoteAddr();

However, keep in mind that the IP address may be misleading if the 
client is going through a proxy or you have a load balancer in front of 
your server or a caching server, etc. I know in a real production system 
you will most likely get a local IP address.  Also, if you want to do 
security based on the IP address, keep in mind that IP addresses can be 
easily spoofed. For this reason I find relying on the IP address to be a 
bad plan.

Tim



Robert Gombotz wrote:

>Hi!
>
>
>I would need to obtain the IP address of clients/consumers that make
>calls to my Web services, preferably using a SOAP handler.
>So far, I have not found a way of achieving this. The MessageContext
>seems to be the only data I have in a handler, and from what I
>understand it does not contain the client's IP.
>
>Any hints and ideas are greatly appreciated.
>
>
>Rob
>
>  
>