The following table lists the APIs to create a Web Services server in BDL.
Note: These functions are valid for backwards compatibility, but they are not the preferred way to handle Genero Web Services. See the GWS COM Library classes and methods.
Function | Description |
fgl_ws_server_setNamespace() | Defines the namespace of the service on the Web. |
fgl_ws_server_start() | Creates and starts the Web Service server. |
fgl_ws_server_publishFunction() | Publishes the BDL function as a Web Function. |
fgl_ws_server_generateWSDL() | Generates the WSDL file. |
fgl_ws_server_process() | Waits for and processes incoming SOAP requests. |
fgl_ws_server_setFault() | Sets the SOAP fault string for a Web Function. |
fgl_ws_server_getFault() | Retrieves the fault string that was set for a Web Function, for testing purposes. |
Purpose:
This function defines the namespace of the service on the Web and must be called first, before all other functions of the API.
Syntax:
FUNCTION fgl_ws_server_setNamespace(namespace VARCHAR)
Parameters:
Return values:
None
Example:
01
CALL fgl_ws_server_setNamespace("http://tempuri.org/")
Purpose:
This function creates and starts the server. For development or testing purposes, you may start a Web Service server as a single server where only one request at a time will be able to be processed. For deployment, you may start a Web Service server with an application server able to handle several connections at one time using a load-balancing algorithm. The value of the parameter passed to the function determines which method is used.
Syntax:
FUNCTION fgl_ws_server_start(tcpPort VARCHAR)
Parameters:
Return values:
None
Examples:
To start a standalone Web Service server:01
CALL fgl_ws_server_start("8080") # A single Server is listening02
# on port number: 8080
To start a Web Service server attempting to connect to an application server:
01
CALL fgl_ws_server_start("zeus:5") # The server attempt to connect02
# to an application server located03
# on host zeus and listening04
# on the port number 6405
Possible runtime errors:
Purpose:
This function publishes the given BDL function as a Web-Function on the Web.
Syntax:
FUNCTION fgl_ws_server_publishFunction(operationName VARCHAR, inputNamespace VARCHAR, inputRecordName VARCHAR, outputNamespace VARCHAR,outputRecord VARCHAR, functionName VARCHAR)
Parameters:
Return values:
None
Example:
01
CALL fgl_ws_server_publishFunction(02
"MyWebOperation",03
"http://www.tempuri.org/webservices/","myfunction_input",04
"http://www.tempuri.org/webservices/","myfunction_output",05
"my_bdl_function")
Possible runtime errors:
Purpose:
This function generates the WSDL file according to the BDL-server program.
Syntax:
FUNCTION fgl_ws_server_generateWSDL(serviceName VARCHAR, serviceLocation VARCHAR, fileName VARCHAR) RETURNING resultStatus INTEGER
Parameters:
Return value:
Example:
01
DEFINE mystatus INTEGER02
03
LET mystatus=fgl_ws_server_generateWSDL(04
"CustomerService",05
"http://localhost:8080",06
"C:/mydirectory/myfile.wsdl")07
08
IF mystatus=0 THEN09
DISPLAY "Generation of WSDL done..."10
ELSE11
DISPLAY "Generation of WSDL failed!"12
END IF
Purpose:
This function waits for an incoming SOAP request for a given time (in seconds) and then processes the request, or returns, if there has been no request during the given time. If a DEFER INTERRUPT or DEFER QUIT instruction has been defined, the function returns even if it is an infinite wait.
Syntax:
FUNCTION fgl_ws_server_process(timeout INTEGER) RETURNING resultStatus INTEGER
Parameter:
Return value:
Example:
01
DEFER INTERRUPT02
DEFINEmystatus
INTEGER
03
LET mystatus=fgl_ws_server_process(5)# wait for 5 seconds04
# for incoming request05
IF mystatus=0 THEN06
DISPLAY "Request processed."07
END IF08
IF mystatus=-1 THEN09
DISPLAY "No request."10
END IF11
IF mystatus=-2 THEN # terminate the application properly12
EXIT PROGRAM # if connected to application server13
END IF14
IF mystatus=-3 THEN15
DISPLAY "Client connection unexpectedly broken."16
END IF17
IF mystatus=-4 THEN18
DISPLAY "Server process has been interrupted."19
END IF20
IF mystatus=-5 THEN21
DISPLAY "Malformed or bad HTTP request received."22
END IF23
IF int_flag<>0 THEN24
LET int_flag=025
EXIT PROGRAM26
END IF
Purpose:
This function can be called in a published Web-Function in order to return a SOAP fault string to the client at the end of the function's execution.
Syntax:
FUNCTION fgl_ws_server_setFault(faultMessage VARCHAR)
Parameter:
Return values:
None
Example:
01
CALL fgl_ws_server_setFault(
"The server is not able to manage this request.")
Purpose:
This function retrieves the last fault string the user has set in a Web-Function, or an empty string if there is none.
Note: This function is only for testing the Web Services functions before they are published on the Web.
Syntax:
FUNCTION fgl_ws_server_getFault() RETURNING faultMessage VARCHAR
Parameters:
None
Return value:
Example:
01
DEFINE div_input RECORD02
a INTEGER,03
b INTEGER04
END RECORD05
06
DEFINE div_output RECORD07
result INTEGER08
END RECORD09
10
FUNCTION TestServices()11
DEFINE string VARCHAR(100)12
...13
# Test divide by zero operation14
LET div_input.a=1515
LET div_input.b=016
CALL service_operation_div()17
LET string=fgl_ws_server_getFault()18
DISPLAY "Operation div error: ", string19
...20
END FUNCTION21
22
FUNCTION service_operation_div()23
...24
IF div_input.b = 0 THEN25
CALL fgl_ws_server_setFault("Divide by zero")26
RETURN27
END IF28
...29
END FUNCTION