Headers and Handlers Demo  Locate

Overview  Locate

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]Note

When using this demo with a .NET client, only the persistently deployed service will work.

Demo Package Description  Locate

The files for this demo are as described in Files and Directories.

Pattern, Class, and Code Discussion  Locate

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

Building and Running Demos  Locate

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:

Runtime Publishing  Locate

To use Runtime Publishing, follow these steps:

  1. Be sure that you have not started SESJ.

  2. Compile the classes in the "demo.advanced.headers.server" package.

    Linux:   ./run.sh make_server
    Windows: run.bat make_server
    
  3. Run the HeadersServer class (it starts SESJ and publishes HeadersService).

    Linux:   ./run.sh run_server
    Windows: run.bat run_server
    
  4. Compile HeadersClient.

    Linux:   ./run.sh make_client
    Windows: run.bat make_client
    
  5. Run HeadersClient (it will call HeadersService).

    Linux:   ./run.sh run_client
    Windows: run.bat run_client
    

Persistent Deployment  Locate

To run using Persistent Deployment: Publish HeadersService on SESJ which is already running.

  1. Be sure that you've started SESJ.

  2. Compile the HeadersService class.

    Linux:   ./run.sh make_service
    Windows: run.bat make_service
    
  3. Deploy the service on the SESJ.

    Linux:   ./run.sh deploy_service
    Windows: run.bat deploy_service
    
  4. Compile HeadersClient.

    Linux:   ./run.sh make_client
    Windows: ./run.bat make_client
    
  5. Run HeadersClient (it will call HeadersService).

    Linux:   ./run.sh run_client
    Windows: ./run.bat run_client
    
  6. Undeploy HeadersService from the SESJ.

    Linux:   ./run.sh undeploy_service
    Windows: run.bat undeploy_service