Hi! It seems like the tip from Andrew Vardeman missed some casting. You need to cast the result like this:
import javax.servlet.http.HttpServletRequest; import org.apache.axis.MessageContext; import org.apache.axis.server.AxisServer; import org.apache.axis.transport.http.HTTPConstants; ..... MessageContext msgContext = AxisServer.getCurrentMessageContext(); HttpServletRequest req = (HttpServletRequest)msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); System.out.println("A client on the IP address " + req.getRemoteHost() + " is accessing my web service."); As you see, I am using this to get the IP address of the client, but the req object above does also have the methods "Cookie[] getCookies()" and "HttpSession getSession()". I have not tried to use these, but I guess it is the latter you need? (Andrew wrote: "...getSession().getId();") Hope this helps (and was not obvious to you). Eirik Wahl -----Original Message----- From: Alexander Lyubshav [mailto:[EMAIL PROTECTED]] Sent: 3. juli 2002 19:45 To: [EMAIL PROTECTED] Subject: Re: confused about cookies > You want something like this: > > MessageContext msgC = MessageContext.getCurrentContext(); > String sessionID = > msgC.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST).getSession().getId(); Ok, that static method makes a lot more sense, thanks for the tip. Still, that cant be the way to access the id, i'm not sure what kind of object you are attemtping to invoke "getSession()" on. These properties are a little bizarre to me. First of all, seems like they are all strings, so taht HTTP_SERVLETREQUEST would be some kind of string which of course doesnt hold any session you can access. I noticed a constant called HEADER_COOKIE so maybe that is a way to directly access the ID. I wouldnt want to have to parse the cookie string for the ID-- It seems like breaking abstraction. > for future reference, the MessageContext is where the Axis developers dump > most stuff you'd want to get at; it has some specific "get" methods as well > as the generic getProperty. HTTPConstants has a list of HTTP Constants > that are used to refer to various HTTP-specific variables you may want to > get at. You might want to take a look at these classes in the API docs; > they can answer a lot of your questions. > > Andrew > > At 10:05 AM 7/3/2002 -0700, you wrote: > > > from within a handler, the session can be retieved using : > > > >But how about from within a service? The interface to my document > >non-rpc service is: > > public Element[] blah(Vector elems) > > > >All I have is the body of the message at that point. Anyone know how to > >access the context? > > > > > > > > public void invoke(MessageContext msgContext) throws AxisFault > > > { > > > Session session = msgContext.getSession(); > > > > > > --Barry > > > > > > -----Original Message----- > > > From: Alexander Lyubshav [mailto:[EMAIL PROTECTED]] > > > Sent: Tuesday, July 02, 2002 11:39 AM > > > To: [EMAIL PROTECTED] > > > Subject: Re: confused about cookies > > > > > > > > > Great, that makes it easier! So, uh, how can I find out the session ID > > > from > > > within the server code? > > > > > > > > > > > > > > >Thanks for your answer. I am not in control of the client though-- it > > > > >doesn't use the Axis framework either. Is there an easy way to do this > > > > >without client support? (Well, of course the client will pass the > > > Cookie > > > > >headers back.) > > > > > > > > I think that's all the Call.setMaintainSession() function does > > > > anyway--tells the client to track the cookie > > > > > > > > > > Alexander, > > > > > > > > > > > > If you want to use cookies for session management, you don't have to > > > add a > > > > > > handler. You just need to specify session scope in your deploy.wsdd > > > and > > > > > > tell the client to maintain session info. Check out this message: > > > > > > > > > > > > http://marc.theaimsgroup.com/?l=axis-user&m=101775995930045&w=2 > > > > > > > > > > > > which provides a real working sample. > > > > > > > > > > > > Andrew > > > > > > > > > > > > At 08:07 AM 7/2/2002 -0700, you wrote: > > > > > > >I looked in the mailing list archives for information on how to add > > > > > cookie > > > > > > >handling to a web service. (HTTP Cookies for sessions. also i'll > > > need > > > > > > >access to the session ID in the program.) > > > > > > > > > > > > > >I was swamped with a big collection of approaches, all of them > > > "well I > > > > > > >haven't done it but this should work" variety. > > > > > > > > > > > > > >What is the common way to do cookie session handling? Does there > > > already > > > > > > >exist a handler for this? if so, how can I add taht to my program, > > > and > > > > > > >get access to the session ID from my pivot method? > > > > > > > > > > > > > >Thanks!! > > > > > > >Alexander > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >