This demo shows how to write and use handlers in SESJ, which in turn consume and produce SOAP headers.
The handler functionality is used to pass authentication information from the client to the server. This authentication information is transported in a SOAP header. The client sets information about its username and password to the call context of the Web Service stub it is using to communicate with the server.
The client handler takes this information and puts it in the outgoing SOAP message. On the server side, the server handler extracts the authentication information from the incoming SOAP message header and stores it to the call context. The Web Service implementation takes this information and returns it to the client in the return value using a simple Java class.
More information about message handlers and SOAP header support is available in the main product guide.
![]() | Note |
---|---|
When using this demo with a .NET client, only the persistently deployed service will work. |
The files for this demo are as described in Files and Directories.
The implementation consists of following files:
src/demo/advanced/headers/server/HeadersService.java - implementation of the Web Service. This class is used for the WSDL generation by SESJ Java2WSDL tool src/demo/advanced/headers/server/AuthenticationInfo.java - simple class used as a return value from the Web Service method src/demo/advanced/headers/server/ServerHandler.java - implementation of the server-side handler src/demo/advanced/headers/client/ClientHandler.java - implementation of the client-side handler src/demo/advanced/headers/server/HeadersServer.java - runs server, publishes service and inserts handler src/demo/advanced/headers/client/HeadersClient.java - client implementation containing the main() method src/package.xml - deployment descriptor of the service package used during persistent deployment
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 classes in the "demo.advanced.headers.server" package.
Linux: ./run.sh make_server Windows: run.bat make_server
Run the HeadersServer class (it starts SESJ and publishes HeadersService).
Linux: ./run.sh run_server Windows: run.bat run_server
Compile HeadersClient.
Linux: ./run.sh make_client Windows: run.bat make_client
Run HeadersClient (it will call HeadersService).
Linux: ./run.sh run_client Windows: run.bat run_client
To run using Persistent Deployment: Publish HeadersService on SESJ which is already running.
Be sure that you've started SESJ.
Compile the HeadersService class.
Linux: ./run.sh make_service Windows: run.bat make_service
Deploy the service on the SESJ.
Linux: ./run.sh deploy_service Windows: run.bat deploy_service
Compile HeadersClient.
Linux: ./run.sh make_client Windows: ./run.bat make_client
Run HeadersClient (it will call HeadersService).
Linux: ./run.sh run_client Windows: ./run.bat run_client
Undeploy HeadersService from the SESJ.
Linux: ./run.sh undeploy_service Windows: run.bat undeploy_service