Writing Web Services in BDL is very easy with the Genero Web Services package. You simply need to create a classic BDL function and publish it as a Web Function (Web Services operation) using methods from the classes in the COM library. There are restrictions on the classic BDL function you create - input and output parameters are not allowed. By using global or module variables, however, to work around this exception.
The steps for writing a Web Services function:
See also Tutorial: Writing a GWS Server Application
As stated in the introduction, input parameters in Genero Web Service operations are not allowed. However, each Web Function can have one global variable or module variable that defines the input message of the function. This variable must be a record in which each field represents one of the input parameters of the Web Function.
The name of each field corresponds to the name used in the SOAP request. These fields are filled with the contents of the SOAP request by the Web Services engine just before executing the corresponding BDL function.
Example:
DEFINE add_in RECORD a INTEGER, b INTEGER END RECORD
Note: Genero version 2.0 allows you to add optional attributes to the definition of data types. You can use attributes to map the BDL data types in a Genero application to their corresponding XML data types. See Attributes to Customize XML Mapping for additional information.
Output parameters in Genero Web Functions are not allowed, but each Web Function can have one global variable or module variable that defines the output message of the function. This message must be a record where each field represents one of the output parameters of the Web Function.
The name of each field corresponds to the name used in the SOAP request. These fields are retrieved from the Web Services engine immediately after executing the BDL function, and sent back to the client.
Example:
DEFINE add_out RECORD r INTEGER END RECORD
Note: GWS 2.0 allows you to add optional attributes to the definition of data types. You can use attributes to map the BDL data types in a Genero application to their corresponding XML data types. See Attributes to Customize XML Mapping for additional information.
A Web Function is a normal BDL function that uses the input and output records that you have defined.
Example:
FUNCTION add() LET add_out.r = add_in.a + add_in.b END FUNCTION
Methods are available in the Genero Web Services library (com) to:
The com library must be imported into each module of a Web Services Server application.
The following abbreviated example is from the Web Services Server tutorial:
IMPORT com ... FUNCTION createservice() DEFINE serv com.WebService # A WebService DEFINE op com.WebOperation # Operation of a WebService--Create WebService object LET serv = com.WebService.CreateWebService("MyCalculator", "http://tempuri.org/webservices") --Create WebOperation object
LET op = com.WebOperation.CreateRPCStyle("add", "Add", add_in, add_out) --Publish the operation, associating it with the WebService object CALL serv.publishOperation(op,NULL) ... END FUNCTION
See the Web Services Server tutorial and Choosing a Web Service Style for complete examples and explanations.