The purpose of the ExceptionsService demo is to show how java exception propagation is handled by the SESJ Web service in runtime. Thrown exceptions may contain any number of fields of any complexity (primitive type, array, sub-class, etc.) which are also (de)serialized between both sides of communication, provided that each field has its own public getter method. The demo.basic.exceptions.server.ExceptionsService class is exposed as the Web service, deployed in the server and called from the client. It has only one method:
public String getItem(int itemIndex) throws InvalidIndexException;
Note that for an itemIndex in range <0,100), this method returns an item stored in a previously generated array of strings. For itemIndexes out of this range, the exception InvalidIndexException is thrown. The exception contains one primitive type (int) indicating the wrong index number, one sub-class (LastItem) containing the lastly asked item and an array of all items having been previously asked (history).
This demo code calls the getItem method for three times where the itemIndex argument is equal to 34 for the first call, 55 for the second call and 101 for the third call. The last call throws the declared exception.
Before the client is compiled, the WSDL description file (automatically generated) is downloaded from the server and stub classes generated. Current implementation follows the JAX-RPC standard published by Sun Microsystems, Inc.
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/basic/exceptions/server/ | Server source code |
src/demo/basic/exceptions/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 the ExceptionsServer class (it starts SESJ and publishes ExceptionsService) ...
Windows: run.bat run_server Linux: ./run.sh run_server (use a new terminal)
You can look at the ExceptionsService WSDL at 'http://localhost:6060/demo/basic/ExceptionsService/wsdl' from your browser.
Make the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run ExceptionsClient (it calls ExceptionsService).
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.
To run using Persistent Deployment:
Be sure that you've started SESJ.
Compile the ExceptionsService class.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy demo.basic.exceptions.server.ExceptionsService 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 demo.basic.exceptions.client.ExceptionsClient (it calls demo.basic.exceptions.server.ExceptionsService).
Windows: run.bat run_client Linux: ./run.sh run_client
Undeploy the demo.basic.exceptions.server.ExceptionsService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service