Get IP informations in AXIS2 SOAP

Get IP informations in AXIS2 SOAP

These days we had this requirements. Just record the SOAP client's IP address.

package com.sillycat.easyaxis2proxy.service;

import javax.servlet.http.HttpServletRequest;

import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.log4j.Logger;

public class BaseWebService {

public Logger logger = Logger.getLogger(this.getClass());

public String getClientIp() {
MessageContext mc = MessageContext.getCurrentMessageContext();
HttpServletRequest request = (HttpServletRequest) mc
.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
logger.info("remote  ip:  " + request.getRemoteAddr());
return request.getRemoteAddr();
}

}

你可能感兴趣的:(apache,log4j,servlet,SOAP)