aspose file tools*
The moose likes Web Services and the fly likes Create Session in Restful Service. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Create Session in Restful Service." Watch "Create Session in Restful Service." New topic
Author

Create Session in Restful Service.

sachin kataria
Ranch Hand

Joined: Mar 27, 2006
Posts: 45
Hi,
I am using Restful Service in Apache CXF for my web application.
I want to know how we create create session and maintain state in REST service.
Is there any examples available ?

Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

You don't. REST architectures are stateless.
Perhaps you could clue us in as to what you are trying to accomplish and we can help you REST-ize it.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
sachin kataria
Ranch Hand

Joined: Mar 27, 2006
Posts: 45
I am creating web-application, in which client will communicate with server.
First client will send request for log-in.
So, client will be authenticate, if its valid then set the user_id into session.
sachin kataria
Ranch Hand

Joined: Mar 27, 2006
Posts: 45
I am using REST service in Apache CXF. so, is there any way in CXF to maintain state ?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

If you store state, you aren't creating a "REST-ful" service.
Which do you want? State or REST?
Is your only concern preserving the logged-in user id?
sachin kataria
Ranch Hand

Joined: Mar 27, 2006
Posts: 45
I want REST services.
Once user is logged id, then it will send several request to server.
So, in that case how session should be maintain ? It should be maintain at client side?

If i want state not REST then how i can do that ?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

I think what you are looking for is container managed security. That way your REST resources don't know or care about the session and remain restful.
sachin kataria
Ranch Hand

Joined: Mar 27, 2006
Posts: 45
I think this is not useful for my application.
I need some another way.
JAX-RS supports @Context.
Can we set cookies ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create Session in Restful Service.