com.WebServiceEngine.RegisterRestResources
Registers the resources of a REST service in the engine.
Syntax
com.WebServiceEngine.RegisterRestResources(
basePath STRING,
info RECORD,
scope STRING,
module STRING [
,...]
)
- basePath defines the path to the REST web service as it appears in the URL.
It may also be used as the name of the Web service if there is no
WSInfo
information. - info defines the record used to generate the service information. If the record
is
NULL
, or information is not specified, the service name will be used by default. - scope defines the global scope (can be
NULL
) - module defines one or more resource modules. The method takes a variable
number of arguments. Several module names can be specified in a comma-separated list with each
module in quotes:
"module1", "module2", "module3"
.
Usage
Use this method to register resources in modules for your web service with the Genero Web Service (GWS) engine and publish the service. If your service has only one module, use the com.WebServiceEngine.RegisterRestService method instead.
For instance, if you have a web service called "fruits" that contains several resources (one per module); where one module is called "apple", and another "peach", you must call the function as shown:
CALL com.WebServiceEngine.RegisterRestResources("fruits", serviceInfo, "scope", "apple", "peach")
You typically deploy the service behind a Genero Application Server (GAS). In the context of the GAS, you therefore may have the group-name (if not a member of the default group) and the service configuration file (xcf-file ) name in the URL before the service name. For example, the URL for the service's OpenAPI specification is:
http[
s]
://host:port/gas/ws/r[
/group-name]
/xcf-file/service-name?openapi.json
For example, a URI to access the "apple" resource "orders" operation is at: http://myhost:6394/gas/ws/r/myGroup/myXcf/fruits/apple/orders
- myhost:6394/gas/ws/r is the base URL from the server.
- myGroup is the name of the group on the GAS where the Web service is deployed.
- myXcf is the name of the Web service configuration .xcf file.
- fruits is the Web service name
- apple is the resource module name
The resource name will always appear in the URI, even if there is only one module.
- orders is the resource-path (defined with WSPath) for the "apple" resource.
For more information on resource URI, see REST resource URI naming practice.
In case of error, the method throws an exception and sets the
status
variable. Depending on the error, a human-readable description of the
problem is available in the sqlca.sqlerrm
register. See Error handling in GWS calls (status).