[jboss-user] [EJB/JBoss] - Re: obtain client ip address in ejb web service endpoint
cripgrm
do-not-reply at jboss.com
Thu Nov 29 16:33:13 EST 2007
I finally figured out how to do this.
Environment is JBoss 4.2.0 GA and JBossws 1.2
Code:
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.WebServiceContext;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.jaxws.WebServiceContextEJB;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.soap.MessageContextAssociation;
@Resource
EJBContext ejbContext;
@Resource
WebServiceContext wsContext;
@WebMethod
public void someMethod()
{
if (wsContext == null)
{
log.debug("WebServiceContext not injected");
CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
wsContext = new WebServiceContextEJB((SOAPMessageContextJAXWS)msgContext, ejbContext);
}
SOAPMessageContextJAXWS jaxwsContext = (SOAPMessageContextJAXWS)wsContext.getMessageContext();
HttpServletRequest hRequest = (HttpServletRequest)jaxwsContext.get(MessageContext.SERVLET_REQUEST);
log.debug("Client IP = " + hRequest.getRemoteAddr());
.....................
.........
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109074#4109074
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109074
More information about the jboss-user
mailing list