Re: Extracting cookies from MessageContext
You can change the instance instantiation mode with WSDL2Java's --deployScope option. Regards, Dies Prashanth.S wrote: smashing!! That gave me a real good idea..Now using what you have said,i can use HTTPSession for stateness of application and use stateless session ejbs... By the way,i see init() and destroy() methods being called for every RPC method even when i set sessions/use sesions on client/server end.. Is it a normal behaviour[which means that for every new rpc request,jax-rpc runtime will be instantiating a new instance of service endpoint interface] Thanks Again Prashanth Dies Koper <[EMAIL PROTECTED]> wrote: Hello Prashanth, Let your impl file implement the javax.xml.rpc.server.ServiceLifeycle interface. Cast the object that gets passed to the init method to javax.xml.rpc.server.ServletEndpointContext. In your business methods, use its getHttpSession() method to get to the HTTP session object associated with the client's method call. (see JAX-RPC1.1 spec section 10.1 for details.) Hope that helps, Dies prashanth shivakumar wrote: Hi Cyrille/robert, Thanks for your response!! There is nothing called "MessageContext.getCurrentContext()" in websphere soap engine!! Its only there in axis webservice engine.Dont know the reason.Therssomething called MessageContext.getCurrentThreadsContext() in one of the MessageContext classes[I say one because i found out 3 different MessageContext classes] I too got stuck into the problem of statefull/stateless webservices and after analysing a lot decided to go with "stateless session bean with maintaining state in HTTPSession object". If i go with POJO[simple stupid java beans],hows session maintainence being done there??How does it do session tracking??does it use cookies to do that??[jsessionID ??] Many Thanks Prashanth On 2/14/06, Cyrille Le Clerc wrote: Hi Prashanth , It is strange to use stateless ejb for a stateful web service? Can you go stateful ? Do you really need ejbs ? Otherwise, simple stupid java beans will gracefully do the job. Syntax will look like a simple "MessageContext.getProperty()" or something like this that will rely on the HttpSession ; I couldn't find Websphere SOAP library documentation to check. Cyrille -- Cyrille Le Clerc [EMAIL PROTECTED] [EMAIL PROTECTED] On 2/14/06, prashanth shivakumar < [EMAIL PROTECTED]> wrote: 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 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 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
Re: Extracting cookies from MessageContext
smashing!! That gave me a real good idea..Now using what you have said,i can use HTTPSession for stateness of application and use stateless session ejbs... By the way,i see init() and destroy() methods being called for every RPC method even when i set sessions/use sesions on client/server end.. Is it a normal behaviour[which means that for every new rpc request,jax-rpc runtime will be instantiating a new instance of service endpoint interface] Thanks Again Prashanth Dies Koper <[EMAIL PROTECTED]> wrote: Hello Prashanth,Let your impl file implement the javax.xml.rpc.server.ServiceLifeycle interface. Cast the object that gets passed to the init method to javax.xml.rpc.server.ServletEndpointContext. In your busines s methods, use its getHttpSession() method to get to the HTTP session object associated with the client's method call.(see JAX-RPC1.1 spec section 10.1 for details.)Hope that helps,Diesprashanth shivakumar wrote:> Hi Cyrille/robert,> > Thanks for your response!!> There is nothing called "MessageContext.getCurrentContext()" in websphere> soap engine!!> Its only there in axis webservice engine.Dont know the> reason.Therssomething called> MessageContext.getCurrentThreadsContext() in one of the MessageContext> classes[I say one because i found out 3 different MessageContext classes]> > I too got stuck into the problem of statefull/stateless webservices and> after analysing a lot decided to go with "stateless session bean> with maintaining state in HTTPSession object".> > If i go with POJO[simple stupid java beans],hows session maintainence being> done there??How does it do session tracking??does it use cookies to do> that??[jsessionID ??]> > Many Thanks> Prashanth> > > > On 2/14/06, Cyrille Le Clerc <[EMAIL PROTECTED]>wrote:>> Hi Prashanth , It is strange to use stateless ejb for a stateful web service? Can you go stateful ? Do you really need ejbs ? Otherwise, simple>> stupid java beans will gracefully do the job. Syntax will look like a>> simple "MessageContext.getProperty()" or something like this that will>> rely on the HttpSession ; I couldn't find Websphere SOAP library>> documentation to check. Cyrille -->> Cyrille Le Clerc>> [EMAIL PROTECTED]>> [EMAIL PROTECTED] On 2/14/06, prashanth shivakumar < [EMAIL PROTECTED]> wrote:>>> 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> -- Dies KOPER <[EMAIL PROTECTED]>(changed on 1 July 2005)Fujitsu Ltd - MWPF1 (changed from MWPF3 on 21 Nov 2005)2-15-16, Shin-Yokohama, Kouhoku-ku, Yokohama, 222-0033, JapanTel. +81(45)-475-5605 (internal 7181-4217) Meet your soulmate! Yahoo! Asia presents Meetic - where millions of singles gather
Re: Extracting cookies from MessageContext
Hello Prashanth, Let your impl file implement the javax.xml.rpc.server.ServiceLifeycle interface. Cast the object that gets passed to the init method to javax.xml.rpc.server.ServletEndpointContext. In your business methods, use its getHttpSession() method to get to the HTTP session object associated with the client's method call. (see JAX-RPC1.1 spec section 10.1 for details.) Hope that helps, Dies prashanth shivakumar wrote: Hi Cyrille/robert, Thanks for your response!! There is nothing called "MessageContext.getCurrentContext()" in websphere soap engine!! Its only there in axis webservice engine.Dont know the reason.Therssomething called MessageContext.getCurrentThreadsContext() in one of the MessageContext classes[I say one because i found out 3 different MessageContext classes] I too got stuck into the problem of statefull/stateless webservices and after analysing a lot decided to go with "stateless session bean with maintaining state in HTTPSession object". If i go with POJO[simple stupid java beans],hows session maintainence being done there??How does it do session tracking??does it use cookies to do that??[jsessionID ??] Many Thanks Prashanth On 2/14/06, Cyrille Le Clerc <[EMAIL PROTECTED] > wrote: Hi Prashanth , It is strange to use stateless ejb for a stateful web service? Can you go stateful ? Do you really need ejbs ? Otherwise, simple stupid java beans will gracefully do the job. Syntax will look like a simple "MessageContext.getProperty()" or something like this that will rely on the HttpSession ; I couldn't find Websphere SOAP library documentation to check. Cyrille -- Cyrille Le Clerc [EMAIL PROTECTED] [EMAIL PROTECTED] On 2/14/06, prashanth shivakumar < [EMAIL PROTECTED]> wrote: 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 -- Dies KOPER <[EMAIL PROTECTED]> (changed on 1 July 2005) Fujitsu Ltd - MWPF1 (changed from MWPF3 on 21 Nov 2005) 2-15-16, Shin-Yokohama, Kouhoku-ku, Yokohama, 222-0033, Japan Tel. +81(45)-475-5605 (internal 7181-4217)
Re: Extracting cookies from MessageContext
Hi Cyrille/robert, Thanks for your response!! There is nothing called "MessageContext.getCurrentContext()" in websphere soap engine!! Its only there in axis webservice engine.Dont know the reason.Thers something called MessageContext.getCurrentThreadsContext() in one of the MessageContext classes[I say one because i found out 3 different MessageContext classes] I too got stuck into the problem of statefull/stateless webservices and after analysing a lot decided to go with "stateless session bean with maintaining state in HTTPSession object". If i go with POJO[simple stupid java beans],hows session maintainence being done there??How does it do session tracking??does it use cookies to do that??[jsessionID ??] Many Thanks Prashanth On 2/14/06, Cyrille Le Clerc <[EMAIL PROTECTED] > wrote: Hi Prashanth , It is strange to use stateless ejb for a stateful web service? Can you go stateful ? Do you really need ejbs ? Otherwise, simple stupid java beans will gracefully do the job. Syntax will look like asimple "MessageContext.getProperty()" or something like this that willrely on the HttpSession ; I couldn't find Websphere SOAP library documentation to check. Cyrille--Cyrille Le Clerc[EMAIL PROTECTED] [EMAIL PROTECTED] On 2/14/06, prashanth shivakumar < [EMAIL PROTECTED]> wrote:>> 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
Re: Extracting cookies from MessageContext
Hi Prashanth , It is strange to use stateless ejb for a stateful web service? Can you go stateful ? Do you really need ejbs ? Otherwise, simple stupid java beans will gracefully do the job. Syntax will look like a simple "MessageContext.getProperty()" or something like this that will rely on the HttpSession ; I couldn't find Websphere SOAP library documentation to check. Cyrille -- Cyrille Le Clerc [EMAIL PROTECTED] [EMAIL PROTECTED] On 2/14/06, prashanth shivakumar <[EMAIL PROTECTED]> wrote: > > 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
Re: Extracting cookies from MessageContext
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 --
Re: Extracting cookies from MessageContext
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) newtestSessionServiceLocator().gettestSessionBinding(); binding.setMaintainSession(true);// invoke remote operationString 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 >
Re: Extracting cookies from MessageContext
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 >