You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Arif Mohd <ar...@wipro.com> on 2010/05/04 10:57:02 UTC

RE: Always new HttpSession object is created when using WebServiceContext

Can any one let me know what am i doing wrong here ?



Arif Mohd wrote:
> 
> 
> Hi Daniel,
> 
>    The service is setup in war and deployed on Websphere application
> server 6.1. Could you please let me know what iam missing here ?
> 
> Regards,
> Arif.
> 
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Tuesday, April 20, 2010 7:42 PM
> To: users@cxf.apache.org
> Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
> Subject: Re: Always new HttpSession object is created when using
> WebServiceContext
> 
> 
> Is your service a service setup as a war or similar running in tomcat or
> is it some sort of standalone "main method" type thing?  If standalone,
> see:
> http://cxf.apache.org/docs/jetty-configuration.html
> for how to turn on the session support for the embedded jetty.
> 
> Dan
> 
> 
> On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
>> Hi,
>>
>>    Iam using CXF version 2.2.5 and trying to implement the stateful
>> webservice by using @Resource annotation to inject WebServiceContext
>>
>>      The code is as follows
>>
>> @WebService(portName ="monitorPort" , endpointInterface =
>> "com.xxx.service.MonitorSEI",
>>         serviceName = "monitorService") public class MonitorService
>> implements MontitorSEI{
>>     @javax.annotation.Resource
>>     private WebServiceContext wsc;
>>
>> 	public List<Names> getNames(){
>>           HttpServletRequest req = (HttpServletRequest)
>> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
>>         Cookie[] cookies=req.getCookies();
>>         if(cookies!=null){
>>         	for(Cookie cookie:cookies){
>>         	System.out.println("************ cookie:"+cookie); //iam
> not
>> getting this SOP
>>         	}
>>         }
>>         HttpSession session = req.getSession();
>>         System.out.println(" ************ is new
>> session:"+session.isNew());//always true
>>    }
>>  }
>>
>> Iam using SOAP UI to send the request and the property "Maintain HTTP
>> Session" is set, i have examined the SOAP request and noticed that the
> 
>> client is returning back JSESSIONID cookie properly.
>>       But still the server is creating a new HttpSession and obviously
> 
>> it is sending new JSESSIONID in next response to the client
>>
>>     I have attached the following interceptor to inbound message of
>> service end point to examine the value of JSESSIONID sent by the
> client.
>>
>> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
>>
>> 	public void handleMessage(Message message) throws Fault {
>> 		Map<String,List<String>> map
>> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
>> 		for(String str:map.keySet()){
>> 			if(str.equals("Set-Cookie")){
>> 				System.out.println("******* cookies");
>> 				List<String>
> lst=(List<String>)map.get(str);
>> 				for(String cookie:lst){
>> 					System.out.println(cookie);
>> 				}
>> 			}
>> 		}
>> 	}
>> }
>>
>>   Can anybody suggest me whats going wrong here ?
> 
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> 
> Please do not print this email unless it is absolutely necessary. 
> 
> The information contained in this electronic message and any attachments
> to this message are intended for the exclusive use of the addressee(s) and
> may contain proprietary, confidential or privileged information. If you
> are not the intended recipient, you should not disseminate, distribute or
> copy this e-mail. Please notify the sender immediately and destroy all
> copies of this message and any attachments. 
> 
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email. 
> 
> www.wipro.com
> 
> 

-- 
View this message in context: http://old.nabble.com/Always-new-HttpSession-object-is-created-when-using-WebServiceContext-tp28287838p28444756.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Always new HttpSession object is created when using WebServiceContext

Posted by Daniel Kulp <dk...@apache.org>.
On Friday 07 May 2010 1:22:07 am Arif Mohd wrote:
> Daniel,
> 
>    One more question is it possible to implement stateful webservice in CXF
> in Object Oriented way as suggested by kawaguchi in his blog
> http://weblogs.java.net/blog/kohsuke/archive/2006/10/stateful_web_se.html

Definitely possible to do with CXF.   There really are two ways to do it:

1) Using the spring aop stuff, you set the service object to be a session 
scope  object.   Spring will automatically handle setting up the session and 
creating a new instance and such.

2) If you dig into the jaxws:endpoint stuff, there is a way (don't remember 
how off hand, you would need to dig a bit) to specify a factory of some sort.   
There is a org.apache.cxf.service.invoker.SessionFactory that can be set to do 
something very similar to the spring thing above.

Hope that helps!

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Always new HttpSession object is created when using WebServiceContext

Posted by Arif Mohd <ar...@wipro.com>.
Daniel,

   One more question is it possible to implement stateful webservice in CXF
in Object Oriented way as suggested by kawaguchi in his blog
http://weblogs.java.net/blog/kohsuke/archive/2006/10/stateful_web_se.html


dkulp wrote:
> 
> 
> This sounds like a bug from the client generating the message.   The
> client 
> shouldn't be setting a "Set-Cookie" header.   The server sets that when it 
> sends the response back to the client.  The client should then be sending
> just 
> a "Cookie" header.
> 
> Dan
> 
> 
> On Wednesday 05 May 2010 9:56:18 am Arif Mohd wrote:
>> Daniel,
>>   One more observation when i tried to print all the HTTPRequestHeaders i
>> found that iam getting Set-Cookie header and its value is also
>> proper(i.e,
>> iam getting the same header value which was sent in previous HTTPRespose)
>> but if i call getCookies() on the HTTPRequest object iam gettting null
>> 
>>       Here is the code snippet
>> 
>> 	public List<Names> getNames(){
>> 
>>                        HttpServletRequest req = (HttpServletRequest)
>>       		  mc.get(MessageContext.SERVLET_REQUEST);
>>                        Enumeration en = req.getHeaderNames();
>>                        while(en.hasMoreElements()){
>>     	                String header = (String)en.nextElement();
>>     	                System.out.println("header:"+header+"
>> value:"+req.getHeader(header));
>>                         }
>>                         Cookie[] cookies=req.getCookies();
>>                          if(cookies!=null){
>>                             for(Cookie cookie:cookies){
>>     	                   System.out.println("************
>> cookie:"+cookie);
>> //iam not getting this SOP
>>                              }
>>                           }
>>                          HttpSession session = req.getSession();
>>                          System.out.println(" ************ is new
>> session:"+session.isNew());//always true
>>                           return null;
>> 	}
>> 
>>       output is :
>> 
>>          header:Accept-Encoding value:gzip,deflate
>>          header:Content-Type value:text/xml;charset=UTF-8
>>          header:SOAPAction value:""
>>          header:Set-Cookie2 value:
>>          header:Set-Cookie
>> value:JSESSIONID=0000zqjYDsVbvL1B71mywyGjis4:-1;
>> Path=/
>>          header:User-Agent value:Jakarta Commons-HttpClient/3.1
>>          header:Host value:myhost:9080
>>          header:Content-Length value:238
>>          ************ is new session:true
>> 
>> dkulp wrote:
>> > On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
>> >> Can any one let me know what am i doing wrong here ?
>> > 
>> > I really have no idea.   The code all looks correct to I'm going to
>> > assume it's a Websphere bug of some sort.
>> > 
>> > Dan
>> > 
>> >> Arif Mohd wrote:
>> >> > Hi Daniel,
>> >> > 
>> >> >    The service is setup in war and deployed on Websphere application
>> >> > 
>> >> > server 6.1. Could you please let me know what iam missing here ?
>> >> > 
>> >> > Regards,
>> >> > Arif.
>> >> > 
>> >> > -----Original Message-----
>> >> > From: Daniel Kulp [mailto:dkulp@apache.org]
>> >> > Sent: Tuesday, April 20, 2010 7:42 PM
>> >> > To: users@cxf.apache.org
>> >> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
>> >> > Subject: Re: Always new HttpSession object is created when using
>> >> > WebServiceContext
>> >> > 
>> >> > 
>> >> > Is your service a service setup as a war or similar running in
>> tomcat
>> >> 
>> >> or
>> >> 
>> >> > is it some sort of standalone "main method" type thing?  If
>> >> > standalone, see:
>> >> > http://cxf.apache.org/docs/jetty-configuration.html
>> >> > for how to turn on the session support for the embedded jetty.
>> >> > 
>> >> > Dan
>> >> > 
>> >> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
>> >> >> Hi,
>> >> >> 
>> >> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
>> >> >> 
>> >> >> webservice by using @Resource annotation to inject
>> WebServiceContext
>> >> >> 
>> >> >>      The code is as follows
>> >> >> 
>> >> >> @WebService(portName ="monitorPort" , endpointInterface =
>> >> >> "com.xxx.service.MonitorSEI",
>> >> >> 
>> >> >>         serviceName = "monitorService") public class MonitorService
>> >> >> 
>> >> >> implements MontitorSEI{
>> >> >> 
>> >> >>     @javax.annotation.Resource
>> >> >>     private WebServiceContext wsc;
>> >> >> 	
>> >> >> 	public List<Names> getNames(){
>> >> >> 	
>> >> >>           HttpServletRequest req = (HttpServletRequest)
>> >> >> 
>> >> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
>> >> >> 
>> >> >>         Cookie[] cookies=req.getCookies();
>> >> >>         if(cookies!=null){
>> >> >>         
>> >> >>         	for(Cookie cookie:cookies){
>> >> >>         	System.out.println("************ cookie:"+cookie); //iam
>> >> > 
>> >> > not
>> >> > 
>> >> >> getting this SOP
>> >> >> 
>> >> >>         	}
>> >> >>         
>> >> >>         }
>> >> >>         HttpSession session = req.getSession();
>> >> >>         System.out.println(" ************ is new
>> >> >> 
>> >> >> session:"+session.isNew());//always true
>> >> >> 
>> >> >>    }
>> >> >>  
>> >> >>  }
>> >> >> 
>> >> >> Iam using SOAP UI to send the request and the property "Maintain
>> HTTP
>> >> >> Session" is set, i have examined the SOAP request and noticed that
>> >> >> the
>> >> >> 
>> >> >> client is returning back JSESSIONID cookie properly.
>> >> >> 
>> >> >>       But still the server is creating a new HttpSession and
>> >> >>       obviously
>> >> >> 
>> >> >> it is sending new JSESSIONID in next response to the client
>> >> >> 
>> >> >>     I have attached the following interceptor to inbound message of
>> >> >> 
>> >> >> service end point to examine the value of JSESSIONID sent by the
>> >> > 
>> >> > client.
>> >> > 
>> >> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
>> >> >> 
>> >> >> 	public void handleMessage(Message message) throws Fault {
>> >> >> 	
>> >> >> 		Map<String,List<String>> map
>> >> >> 
>> >> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
>> >> >> 
>> >> >> 		for(String str:map.keySet()){
>> >> >> 		
>> >> >> 			if(str.equals("Set-Cookie")){
>> >> >> 			
>> >> >> 				System.out.println("******* cookies");
>> >> >> 				List<String>
>> >> > 
>> >> > lst=(List<String>)map.get(str);
>> >> > 
>> >> >> 				for(String cookie:lst){
>> >> >> 				
>> >> >> 					System.out.println(cookie);
>> >> >> 				
>> >> >> 				}
>> >> >> 			
>> >> >> 			}
>> >> >> 		
>> >> >> 		}
>> >> >> 	
>> >> >> 	}
>> >> >> 
>> >> >> }
>> >> >> 
>> >> >>   Can anybody suggest me whats going wrong here ?
>> >> > 
>> >> > --
>> >> > Daniel Kulp
>> >> > dkulp@apache.org
>> >> > http://dankulp.com/blog
>> >> > 
>> >> > Please do not print this email unless it is absolutely necessary.
>> >> > 
>> >> > The information contained in this electronic message and any
>> >> 
>> >> attachments
>> >> 
>> >> > to this message are intended for the exclusive use of the
>> addressee(s)
>> >> > and may contain proprietary, confidential or privileged information.
>> >> > If you are not the intended recipient, you should not disseminate,
>> >> > distribute or copy this e-mail. Please notify the sender immediately
>> >> 
>> >> and
>> >> 
>> >> > destroy all copies of this message and any attachments.
>> >> > 
>> >> > WARNING: Computer viruses can be transmitted via email. The
>> recipient
>> >> > should check this email and any attachments for the presence of
>> >> 
>> >> viruses.
>> >> 
>> >> > The company accepts no liability for any damage caused by any virus
>> >> > transmitted by this email.
>> >> > 
>> >> > www.wipro.com
>> :
>> :confused::confused::confused::confused::confused::confused::confused::conf
>> :used::confused::confused::-((:-((:-((:-((:-((:confused::confused::confused
>> :::confused::confused::confused::confused::confused::confused::confused::co
>> :nfused::confused::confused::confused::confused::confused::confused:
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> 
> 

-- 
View this message in context: http://old.nabble.com/Always-new-HttpSession-object-is-created-when-using-WebServiceContext-tp28287838p28482307.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Always new HttpSession object is created when using WebServiceContext

Posted by Arif Mohd <ar...@wipro.com>.
Thanks Daniel,

    It solved my problem. Actually iam using SOAP UI, since due to some
problem it was not setting cookies properly so i have written the groovy
script to set back the Set-Cookie header in next request.

  

dkulp wrote:
> 
> 
> This sounds like a bug from the client generating the message.   The
> client 
> shouldn't be setting a "Set-Cookie" header.   The server sets that when it 
> sends the response back to the client.  The client should then be sending
> just 
> a "Cookie" header.
> 
> Dan
> 
> 
> On Wednesday 05 May 2010 9:56:18 am Arif Mohd wrote:
>> Daniel,
>>   One more observation when i tried to print all the HTTPRequestHeaders i
>> found that iam getting Set-Cookie header and its value is also
>> proper(i.e,
>> iam getting the same header value which was sent in previous HTTPRespose)
>> but if i call getCookies() on the HTTPRequest object iam gettting null
>> 
>>       Here is the code snippet
>> 
>> 	public List<Names> getNames(){
>> 
>>                        HttpServletRequest req = (HttpServletRequest)
>>       		  mc.get(MessageContext.SERVLET_REQUEST);
>>                        Enumeration en = req.getHeaderNames();
>>                        while(en.hasMoreElements()){
>>     	                String header = (String)en.nextElement();
>>     	                System.out.println("header:"+header+"
>> value:"+req.getHeader(header));
>>                         }
>>                         Cookie[] cookies=req.getCookies();
>>                          if(cookies!=null){
>>                             for(Cookie cookie:cookies){
>>     	                   System.out.println("************
>> cookie:"+cookie);
>> //iam not getting this SOP
>>                              }
>>                           }
>>                          HttpSession session = req.getSession();
>>                          System.out.println(" ************ is new
>> session:"+session.isNew());//always true
>>                           return null;
>> 	}
>> 
>>       output is :
>> 
>>          header:Accept-Encoding value:gzip,deflate
>>          header:Content-Type value:text/xml;charset=UTF-8
>>          header:SOAPAction value:""
>>          header:Set-Cookie2 value:
>>          header:Set-Cookie
>> value:JSESSIONID=0000zqjYDsVbvL1B71mywyGjis4:-1;
>> Path=/
>>          header:User-Agent value:Jakarta Commons-HttpClient/3.1
>>          header:Host value:myhost:9080
>>          header:Content-Length value:238
>>          ************ is new session:true
>> 
>> dkulp wrote:
>> > On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
>> >> Can any one let me know what am i doing wrong here ?
>> > 
>> > I really have no idea.   The code all looks correct to I'm going to
>> > assume it's a Websphere bug of some sort.
>> > 
>> > Dan
>> > 
>> >> Arif Mohd wrote:
>> >> > Hi Daniel,
>> >> > 
>> >> >    The service is setup in war and deployed on Websphere application
>> >> > 
>> >> > server 6.1. Could you please let me know what iam missing here ?
>> >> > 
>> >> > Regards,
>> >> > Arif.
>> >> > 
>> >> > -----Original Message-----
>> >> > From: Daniel Kulp [mailto:dkulp@apache.org]
>> >> > Sent: Tuesday, April 20, 2010 7:42 PM
>> >> > To: users@cxf.apache.org
>> >> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
>> >> > Subject: Re: Always new HttpSession object is created when using
>> >> > WebServiceContext
>> >> > 
>> >> > 
>> >> > Is your service a service setup as a war or similar running in
>> tomcat
>> >> 
>> >> or
>> >> 
>> >> > is it some sort of standalone "main method" type thing?  If
>> >> > standalone, see:
>> >> > http://cxf.apache.org/docs/jetty-configuration.html
>> >> > for how to turn on the session support for the embedded jetty.
>> >> > 
>> >> > Dan
>> >> > 
>> >> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
>> >> >> Hi,
>> >> >> 
>> >> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
>> >> >> 
>> >> >> webservice by using @Resource annotation to inject
>> WebServiceContext
>> >> >> 
>> >> >>      The code is as follows
>> >> >> 
>> >> >> @WebService(portName ="monitorPort" , endpointInterface =
>> >> >> "com.xxx.service.MonitorSEI",
>> >> >> 
>> >> >>         serviceName = "monitorService") public class MonitorService
>> >> >> 
>> >> >> implements MontitorSEI{
>> >> >> 
>> >> >>     @javax.annotation.Resource
>> >> >>     private WebServiceContext wsc;
>> >> >> 	
>> >> >> 	public List<Names> getNames(){
>> >> >> 	
>> >> >>           HttpServletRequest req = (HttpServletRequest)
>> >> >> 
>> >> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
>> >> >> 
>> >> >>         Cookie[] cookies=req.getCookies();
>> >> >>         if(cookies!=null){
>> >> >>         
>> >> >>         	for(Cookie cookie:cookies){
>> >> >>         	System.out.println("************ cookie:"+cookie); //iam
>> >> > 
>> >> > not
>> >> > 
>> >> >> getting this SOP
>> >> >> 
>> >> >>         	}
>> >> >>         
>> >> >>         }
>> >> >>         HttpSession session = req.getSession();
>> >> >>         System.out.println(" ************ is new
>> >> >> 
>> >> >> session:"+session.isNew());//always true
>> >> >> 
>> >> >>    }
>> >> >>  
>> >> >>  }
>> >> >> 
>> >> >> Iam using SOAP UI to send the request and the property "Maintain
>> HTTP
>> >> >> Session" is set, i have examined the SOAP request and noticed that
>> >> >> the
>> >> >> 
>> >> >> client is returning back JSESSIONID cookie properly.
>> >> >> 
>> >> >>       But still the server is creating a new HttpSession and
>> >> >>       obviously
>> >> >> 
>> >> >> it is sending new JSESSIONID in next response to the client
>> >> >> 
>> >> >>     I have attached the following interceptor to inbound message of
>> >> >> 
>> >> >> service end point to examine the value of JSESSIONID sent by the
>> >> > 
>> >> > client.
>> >> > 
>> >> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
>> >> >> 
>> >> >> 	public void handleMessage(Message message) throws Fault {
>> >> >> 	
>> >> >> 		Map<String,List<String>> map
>> >> >> 
>> >> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
>> >> >> 
>> >> >> 		for(String str:map.keySet()){
>> >> >> 		
>> >> >> 			if(str.equals("Set-Cookie")){
>> >> >> 			
>> >> >> 				System.out.println("******* cookies");
>> >> >> 				List<String>
>> >> > 
>> >> > lst=(List<String>)map.get(str);
>> >> > 
>> >> >> 				for(String cookie:lst){
>> >> >> 				
>> >> >> 					System.out.println(cookie);
>> >> >> 				
>> >> >> 				}
>> >> >> 			
>> >> >> 			}
>> >> >> 		
>> >> >> 		}
>> >> >> 	
>> >> >> 	}
>> >> >> 
>> >> >> }
>> >> >> 
>> >> >>   Can anybody suggest me whats going wrong here ?
>> >> > 
>> >> > --
>> >> > Daniel Kulp
>> >> > dkulp@apache.org
>> >> > http://dankulp.com/blog
>> >> > 
>> >> > Please do not print this email unless it is absolutely necessary.
>> >> > 
>> >> > The information contained in this electronic message and any
>> >> 
>> >> attachments
>> >> 
>> >> > to this message are intended for the exclusive use of the
>> addressee(s)
>> >> > and may contain proprietary, confidential or privileged information.
>> >> > If you are not the intended recipient, you should not disseminate,
>> >> > distribute or copy this e-mail. Please notify the sender immediately
>> >> 
>> >> and
>> >> 
>> >> > destroy all copies of this message and any attachments.
>> >> > 
>> >> > WARNING: Computer viruses can be transmitted via email. The
>> recipient
>> >> > should check this email and any attachments for the presence of
>> >> 
>> >> viruses.
>> >> 
>> >> > The company accepts no liability for any damage caused by any virus
>> >> > transmitted by this email.
>> >> > 
>> >> > www.wipro.com
>> :
>> :confused::confused::confused::confused::confused::confused::confused::conf
>> :used::confused::confused::-((:-((:-((:-((:-((:confused::confused::confused
>> :::confused::confused::confused::confused::confused::confused::confused::co
>> :nfused::confused::confused::confused::confused::confused::confused:
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> 
> 

-- 
View this message in context: http://old.nabble.com/Always-new-HttpSession-object-is-created-when-using-WebServiceContext-tp28287838p28482278.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Always new HttpSession object is created when using WebServiceContext

Posted by Daniel Kulp <dk...@apache.org>.
This sounds like a bug from the client generating the message.   The client 
shouldn't be setting a "Set-Cookie" header.   The server sets that when it 
sends the response back to the client.  The client should then be sending just 
a "Cookie" header.

Dan


On Wednesday 05 May 2010 9:56:18 am Arif Mohd wrote:
> Daniel,
>   One more observation when i tried to print all the HTTPRequestHeaders i
> found that iam getting Set-Cookie header and its value is also proper(i.e,
> iam getting the same header value which was sent in previous HTTPRespose)
> but if i call getCookies() on the HTTPRequest object iam gettting null
> 
>       Here is the code snippet
> 
> 	public List<Names> getNames(){
> 
>                        HttpServletRequest req = (HttpServletRequest)
>       		  mc.get(MessageContext.SERVLET_REQUEST);
>                        Enumeration en = req.getHeaderNames();
>                        while(en.hasMoreElements()){
>     	                String header = (String)en.nextElement();
>     	                System.out.println("header:"+header+"
> value:"+req.getHeader(header));
>                         }
>                         Cookie[] cookies=req.getCookies();
>                          if(cookies!=null){
>                             for(Cookie cookie:cookies){
>     	                   System.out.println("************ cookie:"+cookie);
> //iam not getting this SOP
>                              }
>                           }
>                          HttpSession session = req.getSession();
>                          System.out.println(" ************ is new
> session:"+session.isNew());//always true
>                           return null;
> 	}
> 
>       output is :
> 
>          header:Accept-Encoding value:gzip,deflate
>          header:Content-Type value:text/xml;charset=UTF-8
>          header:SOAPAction value:""
>          header:Set-Cookie2 value:
>          header:Set-Cookie value:JSESSIONID=0000zqjYDsVbvL1B71mywyGjis4:-1;
> Path=/
>          header:User-Agent value:Jakarta Commons-HttpClient/3.1
>          header:Host value:myhost:9080
>          header:Content-Length value:238
>          ************ is new session:true
> 
> dkulp wrote:
> > On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
> >> Can any one let me know what am i doing wrong here ?
> > 
> > I really have no idea.   The code all looks correct to I'm going to
> > assume it's a Websphere bug of some sort.
> > 
> > Dan
> > 
> >> Arif Mohd wrote:
> >> > Hi Daniel,
> >> > 
> >> >    The service is setup in war and deployed on Websphere application
> >> > 
> >> > server 6.1. Could you please let me know what iam missing here ?
> >> > 
> >> > Regards,
> >> > Arif.
> >> > 
> >> > -----Original Message-----
> >> > From: Daniel Kulp [mailto:dkulp@apache.org]
> >> > Sent: Tuesday, April 20, 2010 7:42 PM
> >> > To: users@cxf.apache.org
> >> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
> >> > Subject: Re: Always new HttpSession object is created when using
> >> > WebServiceContext
> >> > 
> >> > 
> >> > Is your service a service setup as a war or similar running in tomcat
> >> 
> >> or
> >> 
> >> > is it some sort of standalone "main method" type thing?  If
> >> > standalone, see:
> >> > http://cxf.apache.org/docs/jetty-configuration.html
> >> > for how to turn on the session support for the embedded jetty.
> >> > 
> >> > Dan
> >> > 
> >> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
> >> >> Hi,
> >> >> 
> >> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
> >> >> 
> >> >> webservice by using @Resource annotation to inject WebServiceContext
> >> >> 
> >> >>      The code is as follows
> >> >> 
> >> >> @WebService(portName ="monitorPort" , endpointInterface =
> >> >> "com.xxx.service.MonitorSEI",
> >> >> 
> >> >>         serviceName = "monitorService") public class MonitorService
> >> >> 
> >> >> implements MontitorSEI{
> >> >> 
> >> >>     @javax.annotation.Resource
> >> >>     private WebServiceContext wsc;
> >> >> 	
> >> >> 	public List<Names> getNames(){
> >> >> 	
> >> >>           HttpServletRequest req = (HttpServletRequest)
> >> >> 
> >> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
> >> >> 
> >> >>         Cookie[] cookies=req.getCookies();
> >> >>         if(cookies!=null){
> >> >>         
> >> >>         	for(Cookie cookie:cookies){
> >> >>         	System.out.println("************ cookie:"+cookie); //iam
> >> > 
> >> > not
> >> > 
> >> >> getting this SOP
> >> >> 
> >> >>         	}
> >> >>         
> >> >>         }
> >> >>         HttpSession session = req.getSession();
> >> >>         System.out.println(" ************ is new
> >> >> 
> >> >> session:"+session.isNew());//always true
> >> >> 
> >> >>    }
> >> >>  
> >> >>  }
> >> >> 
> >> >> Iam using SOAP UI to send the request and the property "Maintain HTTP
> >> >> Session" is set, i have examined the SOAP request and noticed that
> >> >> the
> >> >> 
> >> >> client is returning back JSESSIONID cookie properly.
> >> >> 
> >> >>       But still the server is creating a new HttpSession and
> >> >>       obviously
> >> >> 
> >> >> it is sending new JSESSIONID in next response to the client
> >> >> 
> >> >>     I have attached the following interceptor to inbound message of
> >> >> 
> >> >> service end point to examine the value of JSESSIONID sent by the
> >> > 
> >> > client.
> >> > 
> >> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
> >> >> 
> >> >> 	public void handleMessage(Message message) throws Fault {
> >> >> 	
> >> >> 		Map<String,List<String>> map
> >> >> 
> >> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
> >> >> 
> >> >> 		for(String str:map.keySet()){
> >> >> 		
> >> >> 			if(str.equals("Set-Cookie")){
> >> >> 			
> >> >> 				System.out.println("******* cookies");
> >> >> 				List<String>
> >> > 
> >> > lst=(List<String>)map.get(str);
> >> > 
> >> >> 				for(String cookie:lst){
> >> >> 				
> >> >> 					System.out.println(cookie);
> >> >> 				
> >> >> 				}
> >> >> 			
> >> >> 			}
> >> >> 		
> >> >> 		}
> >> >> 	
> >> >> 	}
> >> >> 
> >> >> }
> >> >> 
> >> >>   Can anybody suggest me whats going wrong here ?
> >> > 
> >> > --
> >> > Daniel Kulp
> >> > dkulp@apache.org
> >> > http://dankulp.com/blog
> >> > 
> >> > Please do not print this email unless it is absolutely necessary.
> >> > 
> >> > The information contained in this electronic message and any
> >> 
> >> attachments
> >> 
> >> > to this message are intended for the exclusive use of the addressee(s)
> >> > and may contain proprietary, confidential or privileged information.
> >> > If you are not the intended recipient, you should not disseminate,
> >> > distribute or copy this e-mail. Please notify the sender immediately
> >> 
> >> and
> >> 
> >> > destroy all copies of this message and any attachments.
> >> > 
> >> > WARNING: Computer viruses can be transmitted via email. The recipient
> >> > should check this email and any attachments for the presence of
> >> 
> >> viruses.
> >> 
> >> > The company accepts no liability for any damage caused by any virus
> >> > transmitted by this email.
> >> > 
> >> > www.wipro.com
> :
> :confused::confused::confused::confused::confused::confused::confused::conf
> :used::confused::confused::-((:-((:-((:-((:-((:confused::confused::confused
> :::confused::confused::confused::confused::confused::confused::confused::co
> :nfused::confused::confused::confused::confused::confused::confused:

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Always new HttpSession object is created when using WebServiceContext

Posted by Arif Mohd <ar...@wipro.com>.
Daniel,
  One more observation when i tried to print all the HTTPRequestHeaders i
found that iam getting Set-Cookie header and its value is also proper(i.e,
iam getting the same header value which was sent in previous HTTPRespose)
but if i call getCookies() on the HTTPRequest object iam gettting null  

      Here is the code snippet

	public List<Names> getNames(){ 

                       HttpServletRequest req = (HttpServletRequest) 
      		  mc.get(MessageContext.SERVLET_REQUEST); 
                       Enumeration en = req.getHeaderNames();
                       while(en.hasMoreElements()){
    	                String header = (String)en.nextElement();
    	                System.out.println("header:"+header+"
value:"+req.getHeader(header));
                        }
                        Cookie[] cookies=req.getCookies(); 
                         if(cookies!=null){ 
                            for(Cookie cookie:cookies){ 
    	                   System.out.println("************ cookie:"+cookie);
//iam not getting this SOP 
                             } 
                          } 
                         HttpSession session = req.getSession(); 
                         System.out.println(" ************ is new
session:"+session.isNew());//always true 
                          return null;
	} 

      output is :

         header:Accept-Encoding value:gzip,deflate
         header:Content-Type value:text/xml;charset=UTF-8
         header:SOAPAction value:""
         header:Set-Cookie2 value:
         header:Set-Cookie value:JSESSIONID=0000zqjYDsVbvL1B71mywyGjis4:-1;
Path=/
         header:User-Agent value:Jakarta Commons-HttpClient/3.1
         header:Host value:myhost:9080
         header:Content-Length value:238
         ************ is new session:true
      

dkulp wrote:
> 
> On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
>> Can any one let me know what am i doing wrong here ?
> 
> I really have no idea.   The code all looks correct to I'm going to assume 
> it's a Websphere bug of some sort.
> 
> Dan
> 
> 
>> 
>> Arif Mohd wrote:
>> > Hi Daniel,
>> > 
>> >    The service is setup in war and deployed on Websphere application
>> > 
>> > server 6.1. Could you please let me know what iam missing here ?
>> > 
>> > Regards,
>> > Arif.
>> > 
>> > -----Original Message-----
>> > From: Daniel Kulp [mailto:dkulp@apache.org]
>> > Sent: Tuesday, April 20, 2010 7:42 PM
>> > To: users@cxf.apache.org
>> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
>> > Subject: Re: Always new HttpSession object is created when using
>> > WebServiceContext
>> > 
>> > 
>> > Is your service a service setup as a war or similar running in tomcat
>> or
>> > is it some sort of standalone "main method" type thing?  If standalone,
>> > see:
>> > http://cxf.apache.org/docs/jetty-configuration.html
>> > for how to turn on the session support for the embedded jetty.
>> > 
>> > Dan
>> > 
>> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
>> >> Hi,
>> >> 
>> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
>> >> 
>> >> webservice by using @Resource annotation to inject WebServiceContext
>> >> 
>> >>      The code is as follows
>> >> 
>> >> @WebService(portName ="monitorPort" , endpointInterface =
>> >> "com.xxx.service.MonitorSEI",
>> >> 
>> >>         serviceName = "monitorService") public class MonitorService
>> >> 
>> >> implements MontitorSEI{
>> >> 
>> >>     @javax.annotation.Resource
>> >>     private WebServiceContext wsc;
>> >> 	
>> >> 	public List<Names> getNames(){
>> >> 	
>> >>           HttpServletRequest req = (HttpServletRequest)
>> >> 
>> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
>> >> 
>> >>         Cookie[] cookies=req.getCookies();
>> >>         if(cookies!=null){
>> >>         
>> >>         	for(Cookie cookie:cookies){
>> >>         	System.out.println("************ cookie:"+cookie); //iam
>> > 
>> > not
>> > 
>> >> getting this SOP
>> >> 
>> >>         	}
>> >>         
>> >>         }
>> >>         HttpSession session = req.getSession();
>> >>         System.out.println(" ************ is new
>> >> 
>> >> session:"+session.isNew());//always true
>> >> 
>> >>    }
>> >>  
>> >>  }
>> >> 
>> >> Iam using SOAP UI to send the request and the property "Maintain HTTP
>> >> Session" is set, i have examined the SOAP request and noticed that the
>> >> 
>> >> client is returning back JSESSIONID cookie properly.
>> >> 
>> >>       But still the server is creating a new HttpSession and obviously
>> >> 
>> >> it is sending new JSESSIONID in next response to the client
>> >> 
>> >>     I have attached the following interceptor to inbound message of
>> >> 
>> >> service end point to examine the value of JSESSIONID sent by the
>> > 
>> > client.
>> > 
>> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
>> >> 
>> >> 	public void handleMessage(Message message) throws Fault {
>> >> 	
>> >> 		Map<String,List<String>> map
>> >> 
>> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
>> >> 
>> >> 		for(String str:map.keySet()){
>> >> 		
>> >> 			if(str.equals("Set-Cookie")){
>> >> 			
>> >> 				System.out.println("******* cookies");
>> >> 				List<String>
>> > 
>> > lst=(List<String>)map.get(str);
>> > 
>> >> 				for(String cookie:lst){
>> >> 				
>> >> 					System.out.println(cookie);
>> >> 				
>> >> 				}
>> >> 			
>> >> 			}
>> >> 		
>> >> 		}
>> >> 	
>> >> 	}
>> >> 
>> >> }
>> >> 
>> >>   Can anybody suggest me whats going wrong here ?
>> > 
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://dankulp.com/blog
>> > 
>> > Please do not print this email unless it is absolutely necessary.
>> > 
>> > The information contained in this electronic message and any
>> attachments
>> > to this message are intended for the exclusive use of the addressee(s)
>> > and may contain proprietary, confidential or privileged information. If
>> > you are not the intended recipient, you should not disseminate,
>> > distribute or copy this e-mail. Please notify the sender immediately
>> and
>> > destroy all copies of this message and any attachments.
>> > 
>> > WARNING: Computer viruses can be transmitted via email. The recipient
>> > should check this email and any attachments for the presence of
>> viruses.
>> > The company accepts no liability for any damage caused by any virus
>> > transmitted by this email.
>> > 
>> > www.wipro.com
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> 
> 
:confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::-((:-((:-((:-((:-((:confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused::confused:
-- 
View this message in context: http://old.nabble.com/Always-new-HttpSession-object-is-created-when-using-WebServiceContext-tp28287838p28461265.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Always new HttpSession object is created when using WebServiceContext

Posted by Arif Mohd <ar...@wipro.com>.
Hi Daniel,

     I guess the problem is with injection of WebServiceContext object by
websphere, iam injecting it as follows.

    	@javax.annotation.Resource 
             private WebServiceContext wsc; 

    But Websphere6.1 is not fully JEE compliant server and needs a feature
pack for webservices, i haven't installed webservice feature pack but iam
having ejb3.0 feature pack installed on it.

    Now iam not understanding how it is injecting WebServiceContext if there
is no webservice feature pack installed, it should have injected null.

     Now to isolate this problem is there any way by which i can bind the
WebServiceContext object through CXF configuration into JNDI namespace so
that i can lookup this object from my webservice implementation instead of
gettting injected by AppServer ?

 


dkulp wrote:
> 
> On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
>> Can any one let me know what am i doing wrong here ?
> 
> I really have no idea.   The code all looks correct to I'm going to assume 
> it's a Websphere bug of some sort.
> 
> Dan
> 
> 
>> 
>> Arif Mohd wrote:
>> > Hi Daniel,
>> > 
>> >    The service is setup in war and deployed on Websphere application
>> > 
>> > server 6.1. Could you please let me know what iam missing here ?
>> > 
>> > Regards,
>> > Arif.
>> > 
>> > -----Original Message-----
>> > From: Daniel Kulp [mailto:dkulp@apache.org]
>> > Sent: Tuesday, April 20, 2010 7:42 PM
>> > To: users@cxf.apache.org
>> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
>> > Subject: Re: Always new HttpSession object is created when using
>> > WebServiceContext
>> > 
>> > 
>> > Is your service a service setup as a war or similar running in tomcat
>> or
>> > is it some sort of standalone "main method" type thing?  If standalone,
>> > see:
>> > http://cxf.apache.org/docs/jetty-configuration.html
>> > for how to turn on the session support for the embedded jetty.
>> > 
>> > Dan
>> > 
>> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
>> >> Hi,
>> >> 
>> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
>> >> 
>> >> webservice by using @Resource annotation to inject WebServiceContext
>> >> 
>> >>      The code is as follows
>> >> 
>> >> @WebService(portName ="monitorPort" , endpointInterface =
>> >> "com.xxx.service.MonitorSEI",
>> >> 
>> >>         serviceName = "monitorService") public class MonitorService
>> >> 
>> >> implements MontitorSEI{
>> >> 
>> >>     @javax.annotation.Resource
>> >>     private WebServiceContext wsc;
>> >> 	
>> >> 	public List<Names> getNames(){
>> >> 	
>> >>           HttpServletRequest req = (HttpServletRequest)
>> >> 
>> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
>> >> 
>> >>         Cookie[] cookies=req.getCookies();
>> >>         if(cookies!=null){
>> >>         
>> >>         	for(Cookie cookie:cookies){
>> >>         	System.out.println("************ cookie:"+cookie); //iam
>> > 
>> > not
>> > 
>> >> getting this SOP
>> >> 
>> >>         	}
>> >>         
>> >>         }
>> >>         HttpSession session = req.getSession();
>> >>         System.out.println(" ************ is new
>> >> 
>> >> session:"+session.isNew());//always true
>> >> 
>> >>    }
>> >>  
>> >>  }
>> >> 
>> >> Iam using SOAP UI to send the request and the property "Maintain HTTP
>> >> Session" is set, i have examined the SOAP request and noticed that the
>> >> 
>> >> client is returning back JSESSIONID cookie properly.
>> >> 
>> >>       But still the server is creating a new HttpSession and obviously
>> >> 
>> >> it is sending new JSESSIONID in next response to the client
>> >> 
>> >>     I have attached the following interceptor to inbound message of
>> >> 
>> >> service end point to examine the value of JSESSIONID sent by the
>> > 
>> > client.
>> > 
>> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
>> >> 
>> >> 	public void handleMessage(Message message) throws Fault {
>> >> 	
>> >> 		Map<String,List<String>> map
>> >> 
>> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
>> >> 
>> >> 		for(String str:map.keySet()){
>> >> 		
>> >> 			if(str.equals("Set-Cookie")){
>> >> 			
>> >> 				System.out.println("******* cookies");
>> >> 				List<String>
>> > 
>> > lst=(List<String>)map.get(str);
>> > 
>> >> 				for(String cookie:lst){
>> >> 				
>> >> 					System.out.println(cookie);
>> >> 				
>> >> 				}
>> >> 			
>> >> 			}
>> >> 		
>> >> 		}
>> >> 	
>> >> 	}
>> >> 
>> >> }
>> >> 
>> >>   Can anybody suggest me whats going wrong here ?
>> > 
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://dankulp.com/blog
>> > 
>> > Please do not print this email unless it is absolutely necessary.
>> > 
>> > The information contained in this electronic message and any
>> attachments
>> > to this message are intended for the exclusive use of the addressee(s)
>> > and may contain proprietary, confidential or privileged information. If
>> > you are not the intended recipient, you should not disseminate,
>> > distribute or copy this e-mail. Please notify the sender immediately
>> and
>> > destroy all copies of this message and any attachments.
>> > 
>> > WARNING: Computer viruses can be transmitted via email. The recipient
>> > should check this email and any attachments for the presence of
>> viruses.
>> > The company accepts no liability for any damage caused by any virus
>> > transmitted by this email.
>> > 
>> > www.wipro.com
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> 
> 

-- 
View this message in context: http://old.nabble.com/Always-new-HttpSession-object-is-created-when-using-WebServiceContext-tp28287838p28459793.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Always new HttpSession object is created when using WebServiceContext

Posted by Arif Mohd <ar...@wipro.com>.
It is the basic of any webcontainer to return session object based on
JSESSIONID, any body did tried deploying stateful webservice using cxf on
websphere ?


dkulp wrote:
> 
> On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
>> Can any one let me know what am i doing wrong here ?
> 
> I really have no idea.   The code all looks correct to I'm going to assume 
> it's a Websphere bug of some sort.
> 
> Dan
> 
> 
>> 
>> Arif Mohd wrote:
>> > Hi Daniel,
>> > 
>> >    The service is setup in war and deployed on Websphere application
>> > 
>> > server 6.1. Could you please let me know what iam missing here ?
>> > 
>> > Regards,
>> > Arif.
>> > 
>> > -----Original Message-----
>> > From: Daniel Kulp [mailto:dkulp@apache.org]
>> > Sent: Tuesday, April 20, 2010 7:42 PM
>> > To: users@cxf.apache.org
>> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
>> > Subject: Re: Always new HttpSession object is created when using
>> > WebServiceContext
>> > 
>> > 
>> > Is your service a service setup as a war or similar running in tomcat
>> or
>> > is it some sort of standalone "main method" type thing?  If standalone,
>> > see:
>> > http://cxf.apache.org/docs/jetty-configuration.html
>> > for how to turn on the session support for the embedded jetty.
>> > 
>> > Dan
>> > 
>> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
>> >> Hi,
>> >> 
>> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
>> >> 
>> >> webservice by using @Resource annotation to inject WebServiceContext
>> >> 
>> >>      The code is as follows
>> >> 
>> >> @WebService(portName ="monitorPort" , endpointInterface =
>> >> "com.xxx.service.MonitorSEI",
>> >> 
>> >>         serviceName = "monitorService") public class MonitorService
>> >> 
>> >> implements MontitorSEI{
>> >> 
>> >>     @javax.annotation.Resource
>> >>     private WebServiceContext wsc;
>> >> 	
>> >> 	public List<Names> getNames(){
>> >> 	
>> >>           HttpServletRequest req = (HttpServletRequest)
>> >> 
>> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
>> >> 
>> >>         Cookie[] cookies=req.getCookies();
>> >>         if(cookies!=null){
>> >>         
>> >>         	for(Cookie cookie:cookies){
>> >>         	System.out.println("************ cookie:"+cookie); //iam
>> > 
>> > not
>> > 
>> >> getting this SOP
>> >> 
>> >>         	}
>> >>         
>> >>         }
>> >>         HttpSession session = req.getSession();
>> >>         System.out.println(" ************ is new
>> >> 
>> >> session:"+session.isNew());//always true
>> >> 
>> >>    }
>> >>  
>> >>  }
>> >> 
>> >> Iam using SOAP UI to send the request and the property "Maintain HTTP
>> >> Session" is set, i have examined the SOAP request and noticed that the
>> >> 
>> >> client is returning back JSESSIONID cookie properly.
>> >> 
>> >>       But still the server is creating a new HttpSession and obviously
>> >> 
>> >> it is sending new JSESSIONID in next response to the client
>> >> 
>> >>     I have attached the following interceptor to inbound message of
>> >> 
>> >> service end point to examine the value of JSESSIONID sent by the
>> > 
>> > client.
>> > 
>> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
>> >> 
>> >> 	public void handleMessage(Message message) throws Fault {
>> >> 	
>> >> 		Map<String,List<String>> map
>> >> 
>> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
>> >> 
>> >> 		for(String str:map.keySet()){
>> >> 		
>> >> 			if(str.equals("Set-Cookie")){
>> >> 			
>> >> 				System.out.println("******* cookies");
>> >> 				List<String>
>> > 
>> > lst=(List<String>)map.get(str);
>> > 
>> >> 				for(String cookie:lst){
>> >> 				
>> >> 					System.out.println(cookie);
>> >> 				
>> >> 				}
>> >> 			
>> >> 			}
>> >> 		
>> >> 		}
>> >> 	
>> >> 	}
>> >> 
>> >> }
>> >> 
>> >>   Can anybody suggest me whats going wrong here ?
>> > 
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://dankulp.com/blog
>> > 
>> > Please do not print this email unless it is absolutely necessary.
>> > 
>> > The information contained in this electronic message and any
>> attachments
>> > to this message are intended for the exclusive use of the addressee(s)
>> > and may contain proprietary, confidential or privileged information. If
>> > you are not the intended recipient, you should not disseminate,
>> > distribute or copy this e-mail. Please notify the sender immediately
>> and
>> > destroy all copies of this message and any attachments.
>> > 
>> > WARNING: Computer viruses can be transmitted via email. The recipient
>> > should check this email and any attachments for the presence of
>> viruses.
>> > The company accepts no liability for any damage caused by any virus
>> > transmitted by this email.
>> > 
>> > www.wipro.com
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
> 
> 

-- 
View this message in context: http://old.nabble.com/Always-new-HttpSession-object-is-created-when-using-WebServiceContext-tp28287838p28459459.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Always new HttpSession object is created when using WebServiceContext

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 04 May 2010 4:57:02 am Arif Mohd wrote:
> Can any one let me know what am i doing wrong here ?

I really have no idea.   The code all looks correct to I'm going to assume 
it's a Websphere bug of some sort.

Dan


> 
> Arif Mohd wrote:
> > Hi Daniel,
> > 
> >    The service is setup in war and deployed on Websphere application
> > 
> > server 6.1. Could you please let me know what iam missing here ?
> > 
> > Regards,
> > Arif.
> > 
> > -----Original Message-----
> > From: Daniel Kulp [mailto:dkulp@apache.org]
> > Sent: Tuesday, April 20, 2010 7:42 PM
> > To: users@cxf.apache.org
> > Cc: Arif pasha Mohammed (WT01 - Telecom Equipment)
> > Subject: Re: Always new HttpSession object is created when using
> > WebServiceContext
> > 
> > 
> > Is your service a service setup as a war or similar running in tomcat or
> > is it some sort of standalone "main method" type thing?  If standalone,
> > see:
> > http://cxf.apache.org/docs/jetty-configuration.html
> > for how to turn on the session support for the embedded jetty.
> > 
> > Dan
> > 
> > On Tuesday 20 April 2010 7:09:30 am Arif Mohd wrote:
> >> Hi,
> >> 
> >>    Iam using CXF version 2.2.5 and trying to implement the stateful
> >> 
> >> webservice by using @Resource annotation to inject WebServiceContext
> >> 
> >>      The code is as follows
> >> 
> >> @WebService(portName ="monitorPort" , endpointInterface =
> >> "com.xxx.service.MonitorSEI",
> >> 
> >>         serviceName = "monitorService") public class MonitorService
> >> 
> >> implements MontitorSEI{
> >> 
> >>     @javax.annotation.Resource
> >>     private WebServiceContext wsc;
> >> 	
> >> 	public List<Names> getNames(){
> >> 	
> >>           HttpServletRequest req = (HttpServletRequest)
> >> 
> >> wsc.getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
> >> 
> >>         Cookie[] cookies=req.getCookies();
> >>         if(cookies!=null){
> >>         
> >>         	for(Cookie cookie:cookies){
> >>         	System.out.println("************ cookie:"+cookie); //iam
> > 
> > not
> > 
> >> getting this SOP
> >> 
> >>         	}
> >>         
> >>         }
> >>         HttpSession session = req.getSession();
> >>         System.out.println(" ************ is new
> >> 
> >> session:"+session.isNew());//always true
> >> 
> >>    }
> >>  
> >>  }
> >> 
> >> Iam using SOAP UI to send the request and the property "Maintain HTTP
> >> Session" is set, i have examined the SOAP request and noticed that the
> >> 
> >> client is returning back JSESSIONID cookie properly.
> >> 
> >>       But still the server is creating a new HttpSession and obviously
> >> 
> >> it is sending new JSESSIONID in next response to the client
> >> 
> >>     I have attached the following interceptor to inbound message of
> >> 
> >> service end point to examine the value of JSESSIONID sent by the
> > 
> > client.
> > 
> >> public class HTTPHeaderInterceptor extends SoapHeaderInterceptor{
> >> 
> >> 	public void handleMessage(Message message) throws Fault {
> >> 	
> >> 		Map<String,List<String>> map
> >> 
> >> =(Map<String,List<String>>)message.get(Message.PROTOCOL_HEADERS);
> >> 
> >> 		for(String str:map.keySet()){
> >> 		
> >> 			if(str.equals("Set-Cookie")){
> >> 			
> >> 				System.out.println("******* cookies");
> >> 				List<String>
> > 
> > lst=(List<String>)map.get(str);
> > 
> >> 				for(String cookie:lst){
> >> 				
> >> 					System.out.println(cookie);
> >> 				
> >> 				}
> >> 			
> >> 			}
> >> 		
> >> 		}
> >> 	
> >> 	}
> >> 
> >> }
> >> 
> >>   Can anybody suggest me whats going wrong here ?
> > 
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://dankulp.com/blog
> > 
> > Please do not print this email unless it is absolutely necessary.
> > 
> > The information contained in this electronic message and any attachments
> > to this message are intended for the exclusive use of the addressee(s)
> > and may contain proprietary, confidential or privileged information. If
> > you are not the intended recipient, you should not disseminate,
> > distribute or copy this e-mail. Please notify the sender immediately and
> > destroy all copies of this message and any attachments.
> > 
> > WARNING: Computer viruses can be transmitted via email. The recipient
> > should check this email and any attachments for the presence of viruses.
> > The company accepts no liability for any damage caused by any virus
> > transmitted by this email.
> > 
> > www.wipro.com

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog