Step 2: Import extension packages (com, xml, util)

The functions you need to create a REST Web Service client application are contained in the classes that make up the com package of the Genero Web Services (GWS). Use the IMPORT statement to include the required packages.

Since this example application also uses json and xml class data types for the data exchange, you need to include the following lines at the top of your module as instructions to import the required packages:

IMPORT com    # imports the Genero Web Services Extension package
IMPORT xml    # imports the Genero Web Services xml package
IMPORT util   # imports the util package which provides a set of classes to convert to and from JSON
Inside your module's "MAIN" code block:
  • Declare variables of the com class to handle the HTTP request and response.
  • Declare xml.DomDocument and xml.DomNode objects of the xml class to handle the XML option for data exchange.
MAIN
    DEFINE req com.HttpRequest   # Declare a variable of the com.HttpRequest class    
    DEFINE resp com.HttpResponse # Declare a variable of the com.HttpResponse class
    DEFINE doc xml.DomDocument   # Declare two variables of the xml class for XML data serialization
    DEFINE node xml.DomNode       
    ...
END MAIN

In the next step we define some records Step 3: Define the records