statefull web service
When i call a method in a webservice class from a client, it always call the constructor (stateless) so the data in the class is not being saved. what i need to do for myweb service class to be a statefull and will not create it self everytime i call its methods.
thanks for the help,
Liran
A stateful web service can be run within a servlet container in such a way that it maintains a continuing HTTP session with a SOAP sender. This session management is handled by the JAX-RPC runtime system in one of the following ways:
* Cookie-based mechanism: on the initial method invocation on a service endpoint, the server side JAX-RPC runtime system sends a cookie to the service client to initiate a new session. If service client wants to participate in this session, the client side JAX-RPC runtime system then sends the cookie for each subsequent method invocation on this service endpoint. The cookie associates subsequent method invocations from the service client with the same session.
* URL rewriting involves adding session related identifier to a URL. This rewritten URL is used by the server-side JAX-RPC runtime to associate RPC invocations to the service endpoint with a session.
* SSL session may be used to associate multiple RPC invocations on a service endpoint as part of a single session.
A JAX-RPC session is initiated by the server-side JAX-RPC runtime system. The server-side JAX-RPC runtime system may use javax.servlet.http.HttpSession (defined in the Servlet specification) to implement support for the HTTP session management.
A service client uses the javax.xml.rpc.session.maintain property (set using the Stub or Call interfaces, and False by default) to indicate whether or not it wants to participate in a session with a service endpoint. In the cookie case, the client runtime system accepts the cookie and returns the session tracking information to the server, thereby joining the session.
The client code, by setting the javax.xml.rpc.session.maintain property, assumes that it would participate in a session if one is initiated by the server. The actual session management happens transparent to the client code in the client-side runtime system.
EJB endpoints are implemented as stateless session beans, so they can抰 be used to maintain a conversational state in any way.
Have a look at the following book for full coverage:
Monson-Haefel, R. (2004). J2EE Web Services. Boston: Addison-Wesley.