WSParam

Specifies a value for a template path to a REST Web service resource.

Syntax

WSParam

WSParam is an optional attribute.

Usage

You use this attribute for path templating to specify values that are provided at runtime in function parameters. You set the WSParam attribute in the ATTRIBUTES() clause of the parameter.

For each Genero BDL function parameter with a WSParam attribute, there must be a matching template path in the WSPath. fglcomp checks to ensure that there is one template value per parameter, otherwise compilation error-9111 is thrown.

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
The client application needs to provide an appropriate parameter value when making a call to the function. For example, the variable part of the path (id) is replaced by the integer value /4 in the URL:
http://host:port/gas/ws/r/MyService/accounts/4