Download a large object in the response body
This example demonstrates how to send a large object in the message response body.
To transfer a large object (LOB) to a client, specify a return parameter using a TEXT
or BYTE
data type. The large object is returned in the response body.
Example: downloading a TEXT object
In this sample REST function there is
an example of returning a large object in the message body. The function has two return
parameters:
- A return paramater defined as
INTEGER
with a WSHeader attribute will form a response header. - A return parameter defined as
TEXT
type will have a value transferred in the message body.
t
) is defined as TEXT
and it is located
in memory. The readFile()
method reads the content of a text file
("file3.txt") into the TEXT
variable
(t
). The function's RETURNS
clause returns the
values.PUBLIC FUNCTION help3()
ATTRIBUTES (WSGet,
WSDescription="Download text to the client in a TEXT object",
WSPath="/help/file3")
RETURNS ( INTEGER ATTRIBUTES(WSHeader), TEXT )
DEFINE t TEXT
LOCATE t IN MEMORY
CALL t.readFile("file3.txt")
RETURN 3, t
END FUNCTION
rv0
") at runtime. Use the
WSName
attribute
to rename the
header.RETURNS (INTEGER ATTRIBUTES(WSHeader, WSName="MyHeader"), TEXT)