This demo shows a stateful service and session management in SESJ.
There are two services:
demo.advanced.stateful.server.PerClientService: this service is published with a per-client instantiation flag. Each instance of this service thus corresponds to one client.
demo.advanced.stateful.server.SingletonService: this service is published as a shared instance (by default in SESJ) so there is only one instance for all clients. The service manages sessions by hand and shows how to continue with the session to the next service (demo.advanced.stateful.server.PerClientService).
StatefulClient is able to register a new client to PerClientService and prints this client ID. Each such created ID corresponds to one instance of PerClientService. When the client is called with a given ID the SingletonService uses this ID to talk to the right PerClientService instance.
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/advanced/stateful/server/ | Server source code |
src/demo/advanced/stateful/client/ | Client source code |
You can run the demo using the "run.sh" (for UNIX) or "run.bat" (for Windows) scripts. Running the script without arguments prints out a help message on screen.
The demo can be run in two different ways:
To use Runtime Publishing, follow these steps:
Be sure that you have not started SESJ.
Compile the server classes.
Windows: run.bat make_server Linux: ./run.sh make_server
Run StatefulServer (it starts SESJ and publishes SingletonService and PerClientService classes).
Windows: run.bat run_server Linux: ./run.sh run_server (use a new terminal)
You can look at service WSDLs on 'http://localhost:6060/demo/advanced/stateful/PerClientService/wsdl' and 'http://localhost:6060/demo/advanced/stateful/SingletonService/wsdl' from your browser.
Make the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run StatefulClient (it calls SingletonService and PerClientService).
Windows: run.bat run_client Linux: ./run.sh run_client
You can view the SOAP messages with the SOAPSpy tool. This is in the "server_java60/bin" directory. When running SOAPSpy, use "spy_client" instead of "run_client" as the target.
You can run the demo interactively. In such a case, use "run_client_int" instead of "run_client" as the target. Similarly, use "spy_client_int" to combine both options.
To run using Persistent Deployment:
Be sure that you have started SESJ.
Compile SingletonService and PerClientService.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy SingletonService and PerClientService on the SESJ.
Windows: run.bat deploy_service Linux: ./run.sh deploy_service
Make the client classes.
Windows: ./run.bat make_client Linux: ./run.sh make_client
Run StatefulClient (it calls SingletonService and PerClientService).
Windows: ./run.bat run_client Linux: ./run.sh run_client
Undeploy SingletonService and PerClientService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service