Web Services Guide : Getting Started: Web services in a Day : Exchanging Complex Data in A Web Service
Exchanging Complex Data in A Web Service
This example describes how to create and deploy a web service in a server image and then invoke it from a separate client image on the same machine, passing data which must be represented by complex schema types and mapping specifications before it can be correctly seralized/deseralized by the framework.
It builds on the Document literal Insurance Example section of this guide.
If the data passed between the client and server is of a data type defined by http://www.w3.org/2001/XMLSchema, no mapping specification is necessary since the web services framework creates this schema automatically when the feature is being loaded. (See AbtXmlSchemaTypeFactory (class)>>initializeBaseSchema). However, if more complex objects are required to represent the data they will need to be represented both in a schema and in a mapping specification. For instance the Insurance Policy Example uses the class SstWSPerson to represent people who are policy owners or dependents. The operation getInfoForPolicy sends a policy number as a request and as part of the response, the XML representing a person is returned:
<person>
<tin>815-81-6244</tin>
<name>Jane Doe</name>
<policyNumber>85496328</policyNumber>
<address>
<street>1969 Mockingbird Lane</street>
<city>Cary</city>
<state>NC</state>
<zip>27522</zip>
</address>
</person>
 
In order for this XML to be turned into an instance of SstWSPerson in VAST Platform (VA Smalltalk) two XML definitions need to be present.
 
In the SstWSInsuranceExample.xsd file, which contains a schema, a complex type defining an SstWSPerson needs to be present:
<xsd:complexType name="SstWSPerson">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="tin type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="name" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="policyNumber" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="address" type="tns:SstWSAddress"/>
</xsd:sequence>
</xsd:complexType>
 
The SstWSPerson type is tied to the “person” tag or element name by the complex type definition of SstWSInsurance
<xsd:complexType name="SstPersonCollection">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="person" type="tns:SstWSPerson"/>
</xsd:sequence>
</xsd:complexType>
 
Finally, in the VASTInsuranceExample.map file the XML element
<ClassTypeMapping TypeName="SstWSPerson" ClassName="SstWSPerson"></ClassTypeMapping>
defines which VASmalltalk class should be instantiated for the complex data type SstWSPerson.
(More information on mapping specifications can be found in the ‘XML Support’ Section of the Visual Programming User Guide.) With the two complex type definitions and the mapping specification in place, the web services deserialization framework will correctly instantiate an instance of SstWSPerson with the instance variables set to the values sent in the SOAP envelope.
Creating the Web Service
The steps involved in creating a web service which passes a complex type are:
Generate XML files from a Smalltalk class describing the web service interface using a simple file generation tool, SstWSXmlGeneration;
Generate map and schema files; (for this example, use the map and schema files shipped with VAST Platform).
Modify the deployment descriptor to include the mapping specification file, which is an xml file containing rules that describe how to create Smalltalk objects from the XML in SOAP Envelopes.
Modify the interface WSDL to include a schema file which defines the complex types to be passed in the messages
 
The web service interface WSDL used in this example is described in the introductory section.
Last modified date: 02/12/2021