## Introduction

This version of the Smalltalk Exchange application demonstrates the invocation of a VisualAge Smalltalk server application from a Java client via Web services. You must have the VisualAge Smalltalk Web services beta 0.40 loaded in order to use this demo.

The functionality of the application is broken down into 2 components.

1. Browser client interface (HTML, JSP, Java servlets)
2. VisualAge Smalltalk Web services server

## Browser client interface

The web browser interface is constructed using HTML and JSP files that invoke Java servlets on the application server. The Java servlets are used to route requests to Smalltalk Exchange via Web services requests. The Java Web service client stubs were constructed using Axis Apache 1.0. Be sure to follow all installation instructions for Apache Axis. Make sure that all required .jar files are copied to the correct directory on the application server. Be aware that the Apache Axis installation requires a separately downloadable JAXP-1.1 XML parser. We used the 'xerces.jar' with timestamp (04/11/ 2002 10:05AM). Visit the Xerces web site to download a recent copy of Xerces if necessary.

Below is a summary of the steps required to generate the Java client proxy classes. This is only necessary as an exercise. The generated Java client code (source and executable) is included as part of the demo package in the web archive file .\goodies\SmalltalkExchange\java\vastock_axis.war.

1. Set the Java classpath to include all libraries required by the Axis WSDL2Java tool. For Windows users, the batch file .\java\setclasspath.bat can be customized to perform this task.
2. Use the WSDL2Java tool to create Java code from the VaStockWebService.wsdl document. For Windows users, the batch file .\java\vastock_wsdl2java.bat may simplify this task.

       java org.apache.axis.wsdl.WSDL2Java <goodie_directory>\xml\VaStockWebService.wsdl

   For purposes of the Smalltalk Exchange demo, we created a utility class called HtmlStringFormatter which contains API to create HTML strings from the various Smalltalk Exchange models. We found that creating the utility class was more prudent than adding methods to the generated classes because future versions of Apache Axis may require regeneration of the model classes.

Java client packages
com.ibm.vast.stockdemo.* | Manually coded servlets and helper classes to web enable the Smalltalk Exchange
com.VaStockWebService.www.* | Communications classes to manage HTTP interaction with Smalltalk Exchange remote service. This package was generated by the WSDL2Java tool
com.vast.www.* | Model classes generated by the WSDL2Java tool.

## Server Smalltalk Web services

The operations supported by the Smalltalk Exchange server are found in an interface class named VaStockWebService. Based upon methods with category name @WS-API, various Web service resource files were constructed to externally describe the interface for the Smalltalk service. The required Web services files were initially generated using the SstWSXmlGeneration tool. Customization of files was necessary to properly describe the Smalltalk types and provide accurate endpoints. A summary of commonly required customizations is included in the VisualAge Smalltalk Web Services Guide. Below is a summary of the external resources used by the Smalltalk Exchange Web service.

VaStockWebService.xml | An XML deployment descriptor document containing resources and rules for deploying the Smalltalk Exchange service
VaStockWebService.wsdl | A WSDL document that describes the endpoints for the Smalltalk Exchange service and imports a separate WSDL document containing information about the supported service operations.
VaStockWebService-interface.wsdl | A WSDL document that describes the abstract interface for the Smalltalk Exchange service including parameter descriptions and encoding rules.
vastock.xsd | An XML schema that describes the structure of the arguments required by supported operations
vastockws.map | A Smalltalk mapping specification used to resolve naming disparities between Smalltalk class names and attributes and their XML schema counterparts.
wsserver.wks | A Smalltalk workspace used to start an HTTP server and deploy the Smalltalk Exchange service

## Setting up the demo

This section discusses the steps required to configure the Smalltalk Exchange application for execution under Tomcat or IBM WebSphere Application Server.

### Deploying HTML and Java components

Before setting up the demo, you must first download and install the Apache Axis 1.0. The generated Axis client stubs reference the HTTP URL http://vasthost:63003/SstWSServlet; therefore, you must add an entry to the web server's hosts file to associate vasthost with the IP address of the machine where the Smalltalk Exchange server runs.

Tomcat

- Stop the Tomcat server
- Copy the file .\goodies\SmalltalkExchange\java\vastock_axis.war to the \webapps subdirectory of your Tomcat installation
- Start the Tomcat server

The server automatically expands the contents of the vastock_axis.war file during startup. All required resources should be in place after the server has successfully started.

WebSphere Application Server

Users of WebSphere 4.x can use the IBM WebSphere Application Server Adminstrative Console to configure the Java portion of the demo.

1. Select the target node from the Nodes list, then select Enterprise Applications
2. Select the Install pushbutton and enter the following information

   Path | Specify the file .\goodies\SmalltalkExchange\java\vastock_axis.war. Use Browse... button if necessary to locate the file
   Application Name | Smalltalk Exchange
   Context Root | /vastock_axis

3. Click the Next pushbutton to continue installation of the web app
4. Accept default values, and follow the prompts until installation is completed
5. Save the WAS configuration, and regenerate the 'Plug-in' configuration. If the Web application failed to install, you may not have all Apache Axis required .jar files correctly installed in the WebSphere classpath.
6. Restart the application server to activate the Smalltalk Exchange application

After the web application is successfully installed, the following Java resources will be available:

LoginServlet | com.ibm.vast.stockdemo.LoginServlet
LogoutServlet | com.ibm.vast.stockdemo.LogoutServlet
QueryServlet | com.ibm.vast.stockdemo.QueryServlet
TransactionServlet | com.ibm.vast.stockdemo.TransactionServlet

Loading VisualAge Smalltalk code

Below is a summary of the configuration maps defined for the Smalltalk Exchange application along with the prerequisite VisualAge features. Make sure prerequisite features are loaded prior to attempting to load the Smalltalk Exchange maps.

Map name | Contents | Prerequisites
Goodies - Smalltalk Exchange Web service | Master map for maintaining version information for all Smalltalk Exchange maps | ST: Server, Web Services, VA: XML support
VaStockPortfolioBase | Model classes and general application behavior | ST: Server, Web Services, VA: XML support
VaStockPortfolioWebService | Code to enable stock portfolio operations as Web service | VaStockPortfolioBase

- Copy the entire Smalltalk Exchange directory structure to the VisualAge Smalltalk product directory. The files should be placed in directory <visualage>\goodies BEFORE loading application code. Loading application code before copying the required files will result in an SgmlException walkback because required XML resources cannot be located. Alternatively, add a VaStockBase entry to the XML stanza of the VisualAge .ini file (as shown below) to specify the file path for XML files that are used by Smalltalk Exchange.

      [Xml]
      DefaultResourceQualifier=D:\vast\b47\xml\
      VaStockBase=d:\mystuff\goodies\SmalltalkExchange\xml\

- Start VisualAge Smalltalk
- Load features ST: Server, Web Services and VA: XML Support
- Modify VisualAge environment to import all required maps by swiping and executing this expression:

      EtTools moveAllRequiredMapsToo: true.

- From a configuration maps browser, import all configuration maps from the repository file .\goodies\SmalltalkExchange\manager\smalltalk_exchange.dat Select Goodies - Smalltalk Exchange Web service and the other maps will be brought in automatically.
- Turn off the importing of all required maps by swiping and executing this expression:

      EtTools moveAllRequiredMapsToo: false.

- From a configuration maps browser, use the Load With Required Maps option to load the map named Web Services - Delivery. This map contains code for the VisualAge Smalltalk Web services beta 0.40.
- From a configuration maps browser, use the Load With Required Maps option to load the map named Goodies - Smalltalk Exchange Web service. If an SgmlException occurs during the load, it is likely that required XML resources could not be found. Verify that all steps in this section were completed properly then reload the Smalltalk Exchange map.

Running the application

1. Start the 'Smalltalk Exchange' Web services server. The server can be started in the development image by executing the code in the workspace ..\goodies\SmalltalkExchange\setup\wsserver.wks
2. Start your web server (Tomcat or IBM WebSphere) and verify that Smalltalk Exchange web application is started.
3. Invoke the Smalltalk Exchange by invoking the 'login.html' file from a browser. The URL will be similar to http://myserver/vastock_axis/login.html
4. Enter a valid userid (valid ids are '000001'-'000004'). Enter any value for the password (how's that for security?), and press the 'Login' button. The application should be intuitive

Quotes are retrieved from an ObjectDumper file called vastock.listings. Saved stock prices may not closely match the actual market value. The file was constructed long ago when the stock market was thriving, and investors were happy! Below is the list of saved ticker symbols.

    IBM, QQQ, SUNW, C, YHOO, CSCO, MSFT, QCOM