1 Reply Latest reply on Nov 29, 2007 4:32 PM by Gean Lee

    obtain client ip address in ejb web service endpoint

    Gean Lee Newbie

      I need to capture the client ip address from an ejb web service endpoint.
      The jboss version is 4.2.0GA

      Any help is appreciated.

      cripgrm

        • 1. Re: obtain client ip address in ejb web service endpoint
          Gean Lee Newbie

          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());
          .....................
          .........
          }