Writing a Web server application / Example 2: Writing a GWS server using third-party WSDL (the fglwsdl tool) |
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
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.
# 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
# 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