Step 1: Get the WSDL description and generate files

This tutorial uses fglwsdl and the Calculator Service defined in Example 1: Writing the entire server application to obtain the WSDL information and generate two corresponding BDL files:

fglwsdl -s -o example1 http://localhost:8090/MyCalculator?WSDL
Note: the MyCalculator Genero Web Services Service created in Example 1: Writing the entire server application must be running in order to obtain the WSDL information.

The generated globals file

The globals file example1Service.inc provides the definition of the global input and output records as described in the Step 1: Define input and output records of the Example 1: Writing the entire server application GWS Server program. The names of the input and output records have been assigned by fglwsdl, in accordance with the Style of the Web Service MyCalculator (created as RPCStyle in the Example1 program). Do not modify this file.

Input and output records:
# VARIABLE : Add
DEFINE Add RECORD 
           ATTRIBUTE( XMLName="Add",
                      XMLNamespace="http://tempuri.org/webservices" )
  a INTEGER ATTRIBUTE(XMLName="a",XMLNamespace=""),
  b INTEGER ATTRIBUTE(XMLName="b",XMLNamespace="")
END RECORD

# VARIABLE : AddResponse
DEFINE AddResponse RECORD 
                   ATTRIBUTE(XMLName="AddResponse", 
                             XMLNamespace="http://tempuri.org/webservices" )
  r INTEGER ATTRIBUTE(XMLName="r",XMLNamespace="")
END RECORD

The generated .4gl file

The example1Service.4glfile contains a single function that creates the service, publishes the operation, and registers the Service. The Web Service Style that is created is determined by the style specified in the WSDL information. The functions in this file accomplish the same tasks as Step 3: Create the service and operations and Step 4: Register the service of Example 1. Do not modify this file.
# example1Service.4gl
# Generated file containing the function Createexample1Service

IMPORT com
GLOBALS "example1Service.inc"

# FUNCTION Createexample1Service
#   RETURNING soapstatus
FUNCTION Createexample1Service()
DEFINE service      com.WebService
DEFINE operation    com.WebOperation
  # Set ERROR handler
WHENEVER ANY ERROR GOTO error
  # Create Web Service
LET service = com.WebService.CreateWebService(
                             "MyCalculator",
                             "http://tempuri.org/webservices")
  # Operation: Add
  # Publish Operation : Add
LET operation = com.WebOperation.CreateRPCStyle(
                                 "Add",
                                 "Add",
                                 Add,
                                 AddResponse)
CALL service.publishOperation(operation,"")
  # Register Service
CALL com.WebServiceEngine.RegisterService(service)
RETURN 0
  # ERROR handler
LABEL error:
RETURN STATUS
  # Unset ERROR handler
WHENEVER ANY ERROR STOP
END FUNCTION