web services - Get IP Address of the requested client(Soap message) -
i working on creating soap message , need find requested client ip. have been finding way find client ip still can't. let me know steps how can find client ip when request client?
so want able @ ip address of client consuming web service, within service?
you create class examines of server variables, of pull data http headers. i've found looking @ http_x_forwarded_for , remote_addr trick (ex. in c#):
public class ip { public static string userhostaddress { { return httpcontext.current.request.userhostaddress; } } public static string remote_addr { { return httpcontext.current.request.servervariables["remote_addr"]; } } public static string http_x_forwarded_for { { return httpcontext.current.request.servervariables["http_x_forwarded_for"]; } } public static string http_client_ip { { return httpcontext.current.request.servervariables["http_client_ip"]; } } public static string http_x_forwarded { { return httpcontext.current.request.servervariables["http_x_forwarded"]; } } public static string http_x_cluster_client_ip { { return httpcontext.current.request.servervariables["http_x_cluster_client_ip"]; } } public static string http_forwarded_for { { return httpcontext.current.request.servervariables["http_forwarded_for"]; } } public static string http_forwarded { { return httpcontext.current.request.servervariables["http_forwarded"]; } } public static string ip_address { { if (http_x_forwarded_for != null) { return http_x_forwarded_for; } return remote_addr; } } }
Comments
Post a Comment