Classes with Lists Web Services
The use of Classes with lists in Web Services will be explained using the Class 'car2' which is defined as follows:
type
car2 : class
public
Features : list (alpha 20)
RALColour : list (numeric 4)
end_class
end_definitions
Provided Web Service for Classes with Lists
Provided Web Service Routine
A Provided Web Service always uses a routine defined in a Web Service enabled Form. For example:
begin_routine
if auto2 = NULL
auto2 := car2.create()
endif
auto2.features.add ('Trailer hitch')
auto2.features.add('Climate control')
auto2.features.add('Sunroof')
auto2.features.sort()
auto2.ralcolour.add(9011)
auto2.ralcolour.add(3013)
auto2.ralcolour.add(5001)
auto2.ralcolour.sort(dsc)
end_routine
When no instance is passed to the routine a new one is created, then the lists are filled with new values and sorted. The result is available to the Provided Web Service through the as var defined parameter.
Until AMT 84 'classes' and 'lists' as a routine result parameter were not supported for use with Provided Web Services. Only 'classes' and 'lists' as var defined parameters were supported for use with Provided Web Services. With the release of AMT 84 both 'lists' and 'classes' are supported as routine results including for use with Provided Web Services. |
Creating the Provided Web Service
From this routine a new Provided Web Service can be created using the normal procedure as shown in the Web Services help pages.
It is important that the options in the Provided web service are set to the following values when using lists in web services: SOAP Default style: Document Default use: Literal |
The resulting Operations view will look like the example below.

The returned type should be the Class type and the length will be 1. The Provided Web Service can now be generated and configured in the Provided Web Services web.config and the appropriate <PortType>.ini file.
Testing the Provided Web Service
The Provided Web Service can then be tested using Soap UI as shown below. Best is to import the WSDL into Soap UI using the Web Service itself. Because of the var usage in the Provide Web Service routine, example input values were added in the request.

Returned are the lists values as shown above.
Consumable Web Service for Classes with Lists
Creating the Consumable Web Service
For the consumable web service, the previously created Classes with Lists provided web service example will be used in the same way as shown in the Web Services help pages. The resulting Operations view will look like the example below.

A new class type with the same name as the original will be created from the provided class. This is a local class definition in the Consumable Web Service object, which can be viewed in the Implementation > Definitions menu option.

This local class can be used in other objects to create an instance of it, which can then be filled by a call to the consumable web service.
Consumable Web Service Report
In a report this could look like the following example:
const
var
fleetcar2 : cws_class_lists.car2_web
booleans
end_definitions
routine main
begin_routine
fleetcar2:=cws_class_lists.car2_web.create()
fleetcar2.features.add('DAB+ Radio')
fleetcar2.ralcolour.add(4007)
cws_class_lists.basichttpbinding_iport_class_lists.class_lists_test( fleetcar2 )
sme( 'Number of features :', fleetcar2.features.count )
sme( 'Highest colourcode :', fleetcar2.ralcolour[1] )
end_routine
First a variable (fleetcar2) is defined as the local class of the consumable web service, then an instance of the class is created. This instance has two list items added to it and is then used in the call to the consumable web service, which fills it with data from the provided form routine (see the top of this page). The messages sent by this report will show that the Class instance holds 4 features and the first ralcolour element contains the number 9011.