Single Class Web Services
The use of Classes in Web Services will be explained using the Class 'bike' already defined in the help pages Usage of Classes and Lists of Classes.
Provided Web Service for a Single Class Instance
Provided Web Service Routine
A Provided Web Service always uses a routine defined in a Web Service enabled Form. For example:
begin_routine
if rbike = NULL
rbike := bike.create()
endif
rbike.make := 'Colnago'
rbike.race := true
rbike.bkcolor := 'Red White Black'
rbike.prodyear := 2002
rbike.odometer := 21213
end_routine
When no instance is passed to the routine a new one is created, then the field members are filled with new values and 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. 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 dummy input values are needed in the request.
Returned are the Field members values from the Instance of the Class as shown above.
Consumable Web Service for a Single Class Instance
Creating the Consumable Web Service
For the consumable web service, the previously created single class 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
bicycle : cws_class.bike
booleans
end_definitions
routine main
begin_routine
bicycle:=cws_class.bike.create()
cws_class.basichttpbinding_iport_class.class_test( bicycle )
if SI-SoapResult <> 'LION.OK'
sme('WebService error: ',SI-SoapResult)
exit
endif
sme( bicycle.make )
end_routine
First a variable (bicycle) is defined as the local class of the consumable web service, then an instance of the class is created. This instance is 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).