First of all, stateful web services are something that is best avoided - it will seriously affect the scalability of your service.
If you despite this want to go down that road, you have the following choices, as far as I know:
1. If your web service endpoint is a servlet based endpoint, you can use the same mechanism as you would use in a servlet:
2. If your web service endpoint is EJB based or if you do not want to use the above mechanism for some other reason.
You can implement your own session mechanism by adding a parameter to the requests in your web service. This new parameter is to identify the session that the client participates in. Session data can be stored in memory, alternatively written to database etc.
Joined: Jun 10, 2008
Ok thanks. Yes, I will try to avoid sessions as it is an anti-pattern for SOA.
1. "Servlet-based" end-point. Is there any Java framework that allows that?
2. I am running JAX-WS examples from Netbeans where plain Java classes are being annotated using @WebService. Can I use sessions in such a scenario.
Joined: Oct 04, 2006
ramesh agarwal wrote:2. I am running JAX-WS examples from Netbeans where plain Java classes are being annotated using @WebService. Can I use sessions in such a scenario.
Yes. This is a servlet-based endpoint. Unless the class you annotate with @WebService is an EJB, your endpoint is considered to be servlet-based.
I need to write code that authenticates a user in a web service by generating some kind of a ticket.
Next, as soon as the user is authenticated, a session should start.
As I am completely new to web services, (all I managed till now is a helloworld service.), I need help with this.... what interfaces to implement and so on...
A small snippet would be extremely helpful...