Set a response body and header
Functions that create, update, delete, or get a resource need to set a response body. You specify this in a return parameter without an attribute. Other return values can be sent in headers, using the WSHeader attribute.
Note:
A message body in the response is required when you perform an HTTP GET, POST, PUT, DELETE operation on a resource, otherwise the response results in the error-9106.
Example responses in header and body
PUBLIC FUNCTION help()
ATTRIBUTES (WSGet,
WSPath="/help")
RETURNS (INTEGER ATTRIBUTE(WSHeader, WSDescription="Reference number"),
STRING)
RETURN 3, "Hello world"
END FUNCTION
The help function's
RETURNS
clause has two return values: - An integer is returned in a header. It is specified with the
WSHeader
attribute. - A string is returned in the body. It is specified without an attribute.
In the output the header is given a default name, "rv0", at runtime. You can change default
header naming via the WSName
attribute, for example with:
RETURNS (INTEGER ATTRIBUTE(WSHeader, WSName="MyHeader"), STRING)