473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

getting hold of the session in a jaxrs service

Hi,
I'm trying to get session in the web service implementation class. But I'm webservicecontext is coming as null.. The class and the configuration is as below. How can i get the session or session cookie? It will be great if anyone can provide some help or some example.
*******class*********
Expand|Select|Wrap|Line Numbers
  1. @Path("/userservice/") 
  2. @ProduceMime("application/xml") 
  3. public class CartServiceImpl 
  4.                 implements CartService 
  5.         @Context 
  6.         protected WebServiceContext wsContext; 
  7.  
  8.         @Resource 
  9.         private HttpServletRequest request; 
  10.  
  11.         @Resource 
  12.            public void setContext(WebServiceContext context) 
  13.         { 
  14.                 System.out.println("Request in setContext-->"+ request ); 
  15.                 System.out.println("Setting the context..." + context ); 
  16.  
  17.                  this.request =(HttpServletRequest)context.getMessageContext().get(MessageContext.SERVLET_REQUEST); 
  18.              this.wsContext = context; 
  19.            } 
  20.  
  21.         @POST 
  22.     @Path("/addtocart") 
  23.         public Response addToCart ( Product product ) 
  24.         { 
  25.                  ... .... 
  26.               } 
******** web.xml ******
Expand|Select|Wrap|Line Numbers
  1. <web-app> 
  2.         <servlet> 
  3.                 <display-name>CXF Servlet</display-name> 
  4.                 <servlet-name>CXFServlet</servlet-name> 
  5.                 <servlet-class> 
  6.                         org.apache.cxf.transport.servlet.CXFServlet 
  7.                 </servlet-class> 
  8.                 <load-on-startup>1</load-on-startup> 
  9.         </servlet> 
  10.         <servlet-mapping> 
  11.                 <servlet-name>CXFServlet</servlet-name> 
  12.                 <url-pattern>/*</url-pattern> 
  13.         </servlet-mapping> 
  14. ...<<Spring configuration>> 
  15. </web-app> 
****** spring config file ********
Expand|Select|Wrap|Line Numbers
  1. <beans> 
  2.  <import resource="classpath:META-INF/cxf/cxf.xml" /> 
  3.   <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /> 
  4.   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> 
  5.   <jaxrs:server id="cartService" address="/"> 
  6.     <jaxrs:serviceBeans> 
  7.       <ref bean="cartServiceBean" /> 
  8.     </jaxrs:serviceBeans> 
  9.   </jaxrs:server> 
  10.   <bean id="cartServiceBean" class="com.poc.web.serviceimpl.CartServiceImpl" autowire="autodetect"/> 
  11. </beans> 
}
Apr 28 '09 #1
1 3164
Frinavale
9,735 Expert Mod 8TB
Is this a Java question?
May 1 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Carson Saunders | last post by:
I have a C# client application that calls a web service. I implement the CookieContainer class on the client to ensure the session is kept. However, I'm having trouble with the session timeout. I...
3
by: Nhi Lam | last post by:
Hi, I understand that there are 3 modes in which I can configure the SessionStateModule. What I need is an out of process Session State store with fail over support. The "SQL Server Mode" seems...
3
by: Mark | last post by:
Ok, I know that .net inherently does not share session data across asp.net projects, but is there any decent work around to this. We already have a big chunk of our application using the asp.net...
1
by: giatorta | last post by:
Hi all, I have a scenario where the client calls Web Service WS1 and WS1 calls Web Service WS2 I have methods M1 on WS1 and M2 on WS2 both with EnabledSession=True assume M1 on WS1 does the...
0
by: OldMacDonald | last post by:
I have a Web Service which I call ASynchronously. The problem its not getting kicked off. This is how I am calling it over HTTP and after calling the webservice I have a redirect to another page. I...
4
by: pgmanno | last post by:
Hello all, Here is my question. I have an AxWebBrowser (hereafter refered to as "Browser") control framed in a smart client. The smart client requires logon, and the web app that the Browser...
11
by: Joseph Geretz | last post by:
I've been looking at two approaches for the maintenance of Session state for a Web Service application. One approach uses the old familiar Session object which I've used in the past for Web...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
5
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Hi All, I am using asp.net session state service to store session. The concurrent online user will be almost 2000. Could asp.net session state service afford this? Is there any limitation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.