Get Remote IP Address In Axis SOAP Server

Obtain remote IP from ServletRequest (Axis 1.0 only)

import javax.servlet.http.HttpServletRequest;

import org.apache.axis.MessageContext;

import org.apache.axis.transport.http.HTTPConstants;

public static String getSOAPRemoteIP() {

MessageContext context = MessageContext.getCurrentContext();

String address = null;

if(context!=null &&



HttpServletRequest servletReq = (HttpServletRequest)


if (servletReq != null)

address = servletReq.getRemoteAddr();


return address;



Anonymous said…
Hi, it this works for axis2 to ??
because i tried but it does not work, if you can have a way to help please..
Hakan ISIK said…
Thanks for the comment , i did not try it with axis2.0. if anybody else try in axis2.0 , that will be appreciated.
Anonymous said…
works like a charm in axis2.

MessageContext context = MessageContext.getCurrentMessageContext();
HttpServletRequest servletReq = (HttpServletRequest) context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);

System.out.println("yyyy.MM.dd '-' hh:mm:ss ") + "Request from client " + servletReq.getRemoteAddr() );

Popular posts from this blog

Escape HTML and XML in Java

Read and Write Files in Java