This demo shows how to do the following:
Communicate with a Web service from an HTML Form using a custom interceptor, and
Change an outgoing SOAP message from the Web service to HTML output using XSLTInterceptor
To achieve this, a simple Xslt service and two clients (java and HTML) have been implemented.
Java Client
The java client looks up the service and adds and removes some "to do" items. This client doesn't use any interceptors.
HTML Client
The HTML client works a little differently. The HTML page contains an HTML form that is submitted with the HTTP "post" method. The sent message is processed by the HTMLFormInterceptor, which creates a SOAP message according to the form data. The following parameters are expected by HTMLFormInterceptor:
__methodName - contains the name of method to invoke (required) __methodNamespace - contains the namespace of method (required) __paramOrder - contains the order of parameters of the method (optional) method's parameters - all parameters are listed in __paramOrder (optional)
The XSLTInterceptor and its stylesheet transform the outgoing SOAP message from the Xslt Web service into HTML.
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/advanced/xslt/server/XsltService.java | Implementation of the service (simple ToDo List) |
src/demo/advanced/xslt/server/HTMLFormInterceptor.java | Implementation of the HTMLFormInterceptor (creates a SOAP message from HTML Form parameters) |
src/demo/advanced/xslt/server/out.xsl | Outputs the stylesheet for the XSLTInterceptor |
src/demo/advanced/xslt/client/XsltClient.java | Implementation of the java client |
src/demo/advanced/xslt/server/client/XsltClient.html | HTML for creating request messages from an HTML Form |
src/package.xml | The service's deploymenent descriptor |
The demo assumes that you have installed the following components:
XSLT-Interceptor xsltinterceptor.jar - on the server and client side
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 XsltServer (it starts the SESJ and publishes XsltService class).
Windows: run.bat run_server Linux: ./run.sh run_server (use a new terminal)
You can look at XsltService WSDL on 'http://localhost:6060/demo/advanced/XsltJavaService/wsdl' from your browser.
Make the client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run JavaClient (it calls XsltService).
Windows: run.bat run_client Linux: ./run.sh run_client
Run the HTML client. Open the file demo/advanced/xslt/src/demo/advanced/xslt/client/XsltClient.html in a JavaScript-enabled browser.
If you wish to follow the progress of the invocation with SoapSpy, perform the following:
Run server_java60/bin/soapspy.bat or soapspy.sh. This will bring up the SoapSpy GUI.
Start spying by selecting Start Spying from the Spy menu or by clicking the spy icon in the main pane.
Run the client using the run spy_client command instead of run_client.
To run using Persistent Deployment:
Be sure that you have started SESJ.
Compile the XsltService.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy XsltService 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 the JavaClient (it calls XsltService).
Windows: run.bat run_client Linux: ./run.sh run_client
Run the HTML client. Open the file demo/advanced/xslt/src/demo/advanced/xslt/client/XsltClient.html in a JavaScript-enabled browser.
Undeploy the XsltService from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service