There's a static method MessageContext.getCurrentContext() Since you are using EJB, you could switch to a stateful session bean and have the container control the session:
private String getId(EJBObject session) throws ServiceLocatorException { String id = null; try { Handle handleSoapSession = session.getHandle(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream stream = new ObjectOutputStream(baos); stream.writeObject( handleSoapSession); stream.flush(); stream.close(); id = new String(Base64.encode( baos.toByteArray())); } catch(Exception ex) { throw new ServiceLocatorException( ex.getMessage()); } return id; } That does have the disadvantage of having to return a String to your client and then have him pass it back in. Or maybe set it in the MessageContext as a property. In any case, I've done both with lots of success. The non-ejb way I handle this is using java.util.uuid . HTH, Robert http://www.braziloutsource.com/ Em Terça 14 Fevereiro 2006 13:02, o prashanth shivakumar escreveu: > Hi Cyrille, > Thanks for your response. > SInce iam using ejb endpoint[stateless session EJB] for webservice > implementation using ibm websphere,how can i get hold of MessageContext on > the server end inside stateless session bean?? > > Many Thanks > > On 2/13/06, Cyrille Le Clerc <[EMAIL PROTECTED]> wrote: > > Hello Prashanth, > > > > After your invocation, you have to play with > > "binding._getCall().getMessageContext()" and then get properties > > "HTTPConstants.HEADER_COOKIE" and "HTTPConstants.HEADER_COOKIE2". > > > > Here is a sample : > > TestSessionBindingStub binding = (TestSessionBindingStub) new > > testSessionServiceLocator().gettestSessionBinding(); > > binding.setMaintainSession(true); > > > > // invoke remote operation > > String result = binding.aMethod(); > > > > MessageContext messageContext = binding._getCall().getMessageContext(); > > String cookie1 = (String) > > messageContext.getProperty(HTTPConstants.HEADER_COOKIE); > > String cookie2 = (String) > > messageContext.getProperty(HTTPConstants.HEADER_COOKIE2); > > System.out.println("cookie1=" + cookie1); > > System.out.println("cookie2=" + cookie2); > > > > Hope this helps, > > > > Cyrille > > > > -- > > Cyrille Le Clerc > > [EMAIL PROTECTED] > > [EMAIL PROTECTED] > > > > On 2/7/06, prashanth shivakumar <[EMAIL PROTECTED]> wrote: > > > Hello All, > > > Is there any way wherein i can extract cookies from MessageContext > > > > inside custom MessageHandler. > > > > > I tried using msgContext.getProperty("Cookie"); but it returns NULL > > > Yes..I did set up sessions on both client/server and can see cookie > > > > passing between client/server and viceversa > > > > > Many Thanks --