com.WebServiceEngine.RegisterRestResources
Registers the resources of a REST service in the engine.
Syntax
RegisterRestResources(
basePath STRING,
info RECORD,
scope STRING,
{
module |
package }
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
) - Provides the option to specify one or more resources either in modules or packages.The method
takes a variable number of arguments. Several module names can be specified in a comma-separated
list with each module (42m) in quotes:
"module1", "module2","module3"
or if the modules are in packages:"package.module1","package/subpackage/module2","package.subpackage.module3"
.If service modules are in a package, the package name must have a dot-separated (
"package.module1"
) or slash-separated ("package/module1"
) list corresponding to the path from a top-directory identifying the root of the package tree down to where service modules (42m) are located. For more information on working with packages, refer to the PACKAGE page.
Usage
If your service has only one module, use the com.WebServiceEngine.RegisterRestService method instead.
- If you have a web service called "fruits" that contains several resources (one per module);
where one module is called "apple", and another "peach", import the modules with
IMPORT FGL
statements in your web service application and then call the function to register the web service as shown:IMPORT FGL apple IMPORT FGL peach #... CALL com.WebServiceEngine.RegisterRestResources("fruits", serviceInfo, "scope", "apple", "peach")
- If the "fruits" web service that contains several resources (one per module) is inside a FGL
PACKAGE
; where one module is called "apple", and another "peach", you can import these modules from the package with anIMPORT FGL
statement in your web service application, using either dot notation or slashes in the path and a wildcard (.*
) as shown. Then a call to the function as shown registers the web service:IMPORT FGL myWSPackage.season.* #... # using dot notation CALL com.WebServiceEngine.RegisterRestResources("fruits", serviceInfo, "scope", "myWSPackage.season.apple", "myWSPackage.season.peach") # or using slashes CALL com.WebServiceEngine.RegisterRestResources("fruits", serviceInfo, "scope", "myWSPackage/season/apple", "myWSPackage/season/peach")
Important: Aliasing not supportedUsing an alias on the package name is not supported. For example, this will fail:IMPORT FGL myWSPackage.season.peach AS peach #... CALL com.WebServiceEngine.RegisterRestResources("fruits", serviceInfo, "scope", "peach") -- WILL NOT WORK
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).