XML Samples and Tools
The XML tools and samples are loaded when you load the VA: XML support and XML Examples features. The following tools and samples are provided:
XML Basic Samples
The XML Basic Samples provide simple but complete examples of XML processing using DOM, SAX and mapping parsers. AbtXmlBasicSamples parses an Order XML document and displays it in a DOM tree structure, a Smalltalk object or a mapped root element.
The sample is self-contained; it generates DTD, map, schema and data in files in the directory determined by the default resource qualifies, usually <vas>/xml where <vas> is the installation directory.
Smalltalk class methods parse these files to create the different structures:
AbtXmlBasicSamples domExample.
AbtXmlBasicSamples mappedExample.
AbtXmlBasicSamples saxExample.
 
The mappeded example message is in part
 
| mappingDOM mappingSpec result |
" Create a mapping spec from the order map "
mappingDOM := AbtXmlDOMParser newNonValidatingParser
parseURI: 'order.map'. "The image must contain Smalltalk classes conforming to the map."
mappingSpec := AbtXmlMappingSpec fromMappingDOM: mappingDOM.
" Parse the data "
result := AbtXmlMappingParser newValidatingParser
mappingSpec: mappingSpec;
parseURI: 'order.xml'.
^result abtXmlMappedObject.
 
XML Viewer
The XML viewer, AbtXmlViewer, parses XML files and displays them in a tree structure.
XML Http Client Tester View
The XML Client tester, AbtXmlSampleHttpClientTesterView, provides a graphical user interface to simplify the testing of XML server applications that are accessed via HTTP. This part allows you to unit test your server application without constructing a throwaway front-end client. To specify HTTP headers that should be passed, use the menu item 'Options->HTTP Headers...'. This menu option is useful when sending SOAP strings, since SOAP servers require that the SOAPAction header be specified.
Testing XML request handlers over HTTP
a. From the Organizer, select the AbtXmlServerSamplesUIApp application.
b. Select the AbtXmlSampleHttpClientTesterView part and Test it.
c. Enter an XML string or a piece of code that evaluates to an XML string, e.g. AbtXmlSampleCustomerRequest xmlTestString1
AbtXmlSampleCustomerRequest xmlTestString2
d. From the Actions menu, select the Open WSI monitor option to bring up the Web Server Interface monitor. Follow the instructions in the Web Connection User Guide to start a WSI server with transport type wsi-tcp .
e. Specifiy the URL that will handle the request:
 
http://myserver/cgi-bin/abtwsac.exe/AbtXmlSampleCustomerRequestHandler
 
f. Enable the Options->Inspect result option so that you can view the returned XML response string
g. Select the code string in the text box, and select the Actions->Evaluate and send menu option (or use pop-up menu for text box).
After the command is processed, an inspector should open to display an XML string that contains the results.
XML Socket Client Tester view
The XML Client HTTP tester, AbtXmlSampleSocketClientTesterView, provides a graphical user interface to simplify the testing of XML server applications that are accessed via sockets. This part allows you to unit test your server application without constructing a throwaway front-end client.
Testing XML request handlers over sockets (very similar to the steps for testing over HTTP)
a. From the Organizer, select the AbtXmlServerSamplesUIApp application.
b. Select the AbtXmlSampleSocketClientTesterView part ant test it.
c. Enter an XML string or a piece of code that evaluates to an XML string e.g.
AbtXmlSampleCustomerRequest xmlTestString1
AbtXmlSampleCustomerRequest xmlTestString2
d. From the Actions menu, select the Open WSI monitor option to bring up the Web Server Interface monitor. Start a WSI server with transport type xml-tcp and select the request handler class that you wish to use for handling incoming requests on the socket. For example:
AbtXmlSampleCustomerSaxRequestWsiHandler
e. From the XML socket client tester view, specify the server and port number for the request that is to be made (the same server and port used by WSI Monitor from step #4 above).
f. Enable the Options->Inspect result option so that you can view the returned XML response string.
g. Select the code string in the text box, and select the Actions->Evaluate and send menu option (or use pop-up menu for text box).
After the command is processed, an inspector should open to display an XML string that contains the results.
XML Customer Client view
The XML Customer Client View, AbtXmlSampleCustomerHttpClientView, is a simple example of how customers can use XML as a mechanism for information exchange between client/server applications. The XML Customer Client View can be used to pass information via an HTTP socket request.
XML Customer Request Handler
The XML Customer Request Handler, AbtXmlSampleCustomerRequestHandler, demonstrates the general logic required to construct a simple XML server that is accessed via the Web Server Interface (WSI). The XML Customer Request Handler uses the DOM parser to read in the XML input. It then uses the serialization code to map the DOM into a customer object, AbtXmlSampleCustomer.
XML Sample SAX Customer Request WSI Handler
The XML Sample SAX Customer Request Handler, AbtXmlSampleSaxCustomerWsiRequestHandler, is a subclass of the AbtXmlSampleCustomerRequestHandler class that uses the same logic as the XML Customer Request Handler. The XML Sample SAX Customer Request Handler uses a SAX parser with a customer SAX handler to map the XML directly into a customer object.
Last modified date: 07/27/2020