1 Reply Latest reply on Nov 1, 2007 3:30 AM by Adinarayana gunnam

    Hold the client ip from the client calls made to the web se

    Adinarayana gunnam Newbie

      Hi

      I am working on Ejb3 web services.I want to hold the client ip from the client calls made

      to the web service.I deployed this service in jboss AS 4.2.1

      In the service implementation i started using

      @Resource
      SessionContext sessionCtx;


      My idea is to get the MessageContext from this SessionContext and finally to

      get the HttpServletRequest.


      I got the sessionCtx(BaseSessionContext) object.When i am trying to access the

      MessageContect using the below syntax

      System.out.println(sessionCtx.getMessageContext());


      I got ---ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      javax.ejb.EJBException: java.lang.IllegalStateException: No message context found



      Please provide me with correct solution to this problem.Please also suggest if there is any

      alternate approach to get the client ip in the service implementation.

      Thanks
      Adinarayana

        • 1. Re:  Hold the client ip from the client calls made to the we
          Adinarayana gunnam Newbie

          Hi
          I got the solution for this problem.
          I got the implementation class for the WebServiceContextImpl class.I hope this it is not been implemented in jars provided.
          I found a method to get the messagecontext.
          i.e

          public MessageContext getMessageContext()
          {
          CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
          if(msgContext instanceof SOAPMessageContextJAXWS)
          return (SOAPMessageContextJAXWS) msgContext;
          else
          return new SOAPMessageContextJAXWS(msgContext);
          }


          plesae import the jar C:\JBOSS\server\all\deploy\jbossws.sar\jbossws- core to get all the classesequired for this method

          I used the obtained message context from this method to obtain the ip addtress as below

          MessageContext mc=getMessageContext();
          System.out.println(((javax.servlet.ServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getRemoteAddr());




          Thanks
          Adinarayana