AMT Help Files

List of Classes 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 List of Class Instances

Provided Web Service Routine

As example the following Provided Web Service routine is created in a Web Service enabled Form:

routine class_list_test (var bikenr : numeric 2var result_list : list (bike))
var
    ibike : bike
    i     : integer
begin_routine

    if bikenr < 1
        exit
    endif

    loop for i := 1 to bikenr

        ibike          := bike.create()
        ibike.make     := 'Make ' + format(i)
        ibike.race     := true
        ibike.bkcolor  := 'Color ' + format(i)
        ibike.prodyear := 2000 + i
        ibike.odometer := 54321 + i

        result_list.add(ibike)

    endloop

end_routine

It takes an input of the number of bike instances to add in the list (bikesnr) and will return a list with bikesnr bike instances using the list variable result_list to the Provided Web Service.

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 for the list 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. The only input needed is the number of instances in the list (bikenr) that should be returned.

Returned is an array containing all the Field members values of the Class Instances as shown above.

 

Consumable Web Service for a List of Class Instances

Creating the Consumable Web Service

For the consumable web service, the previously created list of class instances 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.

Just like the single class consumable web service, a list with a different class type than the original list of class instances will be created from the provided list of class instances. 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:

 

begin_definitions
const

var

    
bicyclenr : integer
    
bicycle   : cws_class_list.bike
    
bikelist  : list (cws_class_list.bike)
    
i         : numeric 2

booleans

end_definitions

routine
main
begin_routine

    
bicycle   := cws_class_list.bike.create()

    
bicyclenr := 3

    
cws_class_list.basichttpbinding_ipost_class_list.class_list_test(bicyclenr, bikelist)

    loop for
I := 1 to bikelist.count

        
bicycle := bikelist[i]

        sme
(bicycle.make, bicycle.bkcolor)

    endloop

end_routine