Supported Data Types in Client Web Services
Client web services have the same capabilities as server web services. The parameters may consist of any of the following:
- Fundamental data types: These are the built-in simple data types (e.g., string, integer).
- Struct data types: These are custom data types created using the
structcommand (e.g.,tMyOrder). - Arrays: These can be arrays of fundamental or struct data types (e.g.,
string[],integer[][],MyOrder[]). - Handle: This is a special type that indicates that the data is passed as XML.
When a client web service class is created, the class generator will recognize if structs or arrays are defined in the service definition. If structs are needed, they will be created in your class package by the class generator. The name of the struct will be prefaced with the tWS prefix to indicate that the struct is defined within a web service. When you call this web service, you will pass and return the struct data types and arrays as needed.
The following example assumes that the web service returns an array of structs of tWSCustomer type. Its interface would appear as follows:
// Interface:
//
// Function wsGetCustomers returns tWSCustomer[]
It can be called and used as follows:
Procedure OnClick
tWSCustomer[] ArrayOfCustomer
Integer iCust iCustomers eStatus
Get wsGetCustomers of oWSCustomerService to ArrayOfCustomer
Get peTransferStatus of oWSCustomerService to eStatus
If (eStatus = wssOK) begin
Move (SizeOfArray(ArrayOfCustomer)) to iCustomers
For iCust from 0 to (iCustomers - 1)
Send ProcessOneCustomer ArrayOfCustomer[iCust]
Loop
End
End_Procedure // OnClick
By Reference Parameters in a Client Web Service
If the web service you are calling uses in/out parameters (where the same parameter is used to pass data in and data out), your client will support this by using the BYREF keyword in your method. You will see this in your method declarations. Here is an example of a web service that has an in/out parameter declaration:
// Interface:
//
// Function wsSaveOrder tOrder BYREF MyOrder returns Boolean
If BYREF is used, you must call the method using the by-reference parameter passing syntax. This is done by placing the variable within the (& ) markers (e.g., (&MyParameter)). The above method would be called as follows:
Procedure OnClick
tWSOrder TheOrder
Boolean bOk
Integer eStatus
Get wsSaveOrder of oMyWebService (&TheOrder) to bOk
Get peTransferStatus of oWSCustomerService to eStatus
If (eStatus = wssOK and bOk) begin
Send ProcessOneOrder TheOrder
End
End_Procedure // OnClick
While in/out parameters are not usually used in web services, they are fully supported.