Results 1 to 3 of 3
- 10-06-2011, 02:45 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 8
- Rep Power
- 0
How to get client ip address from Web Service hosted on OAS 10.1.2
Hi,
Can anyone advice how to get the remote client IP from a web service (java) hosted on Oracle Application Server 10.1.2.
The below code works if the web service is hosted on Tomcat.
MessageContext msgCtxt = MessageContext.getCurrentMessageContext();
String IP = (String)msgCtxt.getProperty("REMOTE_ADDR");
This code is causes built errors on the OAS 10.1.2 since it needs Axis and many other Jars. I tried to insert the jars needed but unfortunately when i was able to compile it returned a java.lang.NullPointerException.
Is there a way to get the IP address of the client that calls this web service ?
Or is there a way to read the SOAP request maybe i can retrieve the client IP from it.
Thanks for your support,
regards
- 10-06-2011, 03:05 PM #2
Member
- Join Date
- Feb 2011
- Location
- Ahmedabad
- Posts
- 36
- Rep Power
- 0
Re: How to get client ip address from Web Service hosted on OAS 10.1.2
[Sample Code]
===========
[WebMethod]
In above sample code, HTTP_VIA is used to judge whether the client is using proxy server. If client uses proxy server, then the web method will try to obtain IP address behind the proxy server. In many situations, the IP addresses we get are probably the addresses of proxy server. Below is the information on HTTP proxy:Java Code:public string GetCustomerIP() { string CustomerIP = ""; if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null) { CustomerIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else { CustomerIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); } return CustomerIP; }
1. Not Use Any Proxy Server:
REMOTE_ADDR = IP address of client
HTTP_VIA = No value or No display
HTTP_X_FORWARDED_FOR = No value or No display
2. Use Transparent Proxies:
REMOTE_ADDR = IP address of proxy server
HTTP_VIA = IP address of proxy server
HTTP_X_FORWARDED_FOR = Real IP address of client
3. Use Normal Anonymous Proxies:
REMOTE_ADDR = IP address of proxy server
HTTP_VIA = IP address of proxy server
HTTP_X_FORWARDED_FOR = IP address of proxy server
4. Use Distorting Proxies:
REMOTE_ADDR = IP address of proxy server
HTTP_VIA = IP address of proxy server
HTTP_X_FORWARDED_FOR = Random IP address
5. Use High Anonymity Proxies (Elite proxies):
REMOTE_ADDR = IP address of proxy server
HTTP_VIA = No value or No display
HTTP_X_FORWARDED_FOR = No value or No display
Another fact that may affect the result of above web service is the configuration of router. If the router of local area network enables NAT (network address translation), then the IP address obtained is the address used by the router to access external network. If NAT is disabled, then the IP address is the client's IP address within local area network.
Before use above sample code, we should first consider the real product environment and then use it accordingly.
Reference
========
A Probability to Get Wrong Information
KBSoft IP Locator - CodeProject
Getting the Real IP Of Your Users
Getting The Real IP Of Your UsersLast edited by hemant_metalia; 10-06-2011 at 03:07 PM.
Hemant Metalia
cool-.gif)
- 10-06-2011, 03:47 PM #3
Member
- Join Date
- Apr 2010
- Posts
- 8
- Rep Power
- 0
Re: How to get client ip address from Web Service hosted on OAS 10.1.2
Thanks for your quick reply.
I tried the above code in my environment but unfortunately it didn't work because Oracle Application Server 10.1.2 works on java 1.4 :(
I added the http.jar file but unfortunately the following code "HttpContext.Current.Request.ServerVariables["HTTP_VIA"] " is in error and i'm not able to compile.
Is there any way I can get it to work. Are there any jar file i should use ?
Thanks
Lana
Similar Threads
-
gwt 2.0 hosted mode "plugin failed to connect to hosted mode server"
By turanan in forum New To JavaReplies: 0Last Post: 03-18-2010, 05:39 PM -
Getting client IP address
By shinjan in forum JavaServer Pages (JSP) and JSTLReplies: 6Last Post: 12-20-2009, 12:36 AM -
Client IP Address
By goodjonx in forum NetworkingReplies: 3Last Post: 09-23-2009, 10:27 AM -
Web service client
By Tshegofatsom in forum New To JavaReplies: 1Last Post: 09-09-2009, 02:31 PM -
How to get IP Address of the client
By Java Tip in forum java.netReplies: 0Last Post: 04-05-2008, 10:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks