WSPath
Specifies a path to a REST Web service resource that identifies its function and allows parameters to be passed in the URL.
Syntax
WSPath = "/{ path-element | value-template } [/...]"
identifier
{identifier}
- path-element is a slash-separated list of path elements
- value-template elements are place holders for a slash-separated list of variable values.
Usage
WSPath="/users"
WSPath
string begins with a slash (/
), and there is a slash between each path element
and/or template value. WSPath=/users/{id}
The path template is an identifier enclosed in curly brackets {}
. Zero, one, or
several path templates can be specified. Values are substituted when a GWS client makes a call to
the resource.
Path template values are provided at runtime in function parameters which have WSParam
attributes. As many template
values as path templates must be specified. In other words there must be a function parameter with a
WSParam
attribute to match each template path. fglcomp checks to
ensure that there is one template value per parameter, otherwise compilation error-9111 is thrown.
You set the WSPath
attribute in the ATTRIBUTES()
clause of the
function. WSPath
is an optional attribute. If there is no WSPath
specified, the function name (case sensitive) is the path to the resource in the URL.
Example path templating with WSParam
TYPE accountType RECORD ... END RECORD
PUBLIC FUNCTION getAccountById(id INTEGER ATTRIBUTE(WSParam))
ATTRIBUTES(WSGet,
WSPath="/accounts/{id}",
WSDescription="Returns an account record",
WSThrows="404:not found"
)
RETURNS accountType ATTRIBUTES(WSName="Account",WSMedia="application/xml")
DEFINE p_accountRec accountType
# ... function code ...
RETURN p_accountRec.*
END FUNCTION
/4
in the
URL:http://host:port/gas/ws/r/MyService/accounts/4