Writing a Web server application / Example 1: Writing the entire server application |
The Genero Web Services library (com) provides classes and methods that allow you to use Genero BDL to configure a Web Service and its operations.
FUNCTION createservice() DEFINE serv com.WebService # A WebService DEFINE op com.WebOperation # Operation of a WebService
XML uses namespaces to group the element and attribute definitions, and to avoid conflicting names. In practice, a namespace must be a unique identifier (URI: Uniform Resource Identifier). If you do not know the unique identifier to use, your company's Web site domain name is guaranteed to be unique (such as "www.mycompany.com"); then, append any string.
Examples of valid namespaces for the fictional My Company company:
Another option (for testing only) is to use the temporary namespace "http://tempuri.org/".
Call the constructor method of the WebService class. The parameters are:
LET serv = com.WebService.CreateWebService("MyCalculator", "http://tempuri.org/webservices")
A WebService object can have multiple operations. The operations can be created in RPC style or Document style by calling the corresponding constructor method of the WebOperation class. The parameters are:
LET op = com.WebOperation.CreateRPCStyle("add", "Add", add_in, add_out)
LET op = com.WebOperation.CreateDOCStyle("add", "Add", add_in, add_out)
Mixing RPC style and Document style operations in the same service is not recommended, as it is not WS-I compliant. See Web Services Styles for additional information about styles.
The rest of the code in your application is the same, regardless of the Web Services style that you have chosen.
Once an operation is defined, it must be associated with its corresponding WebService (the operation must be published). The publishOperation method of the WebService object has the following parameters:
CALL serv.publishOperation(op,NULL)