HTTP Input and Field Validation
Â
Universal Display File programs can read HTTP input when running under the Web Connector by performing a READ operation on a record format with the "input parameters" property specified. This property maps HTTP parameters in the query string or POST data to fields in the display file record:
Â
The "parameter name" is the name of a query string or POST data parameter to read. The name is case-sensitive. The "bound field" specifies a field in the record format to receive the data. Multiple parameters can be specified by using the Add button.
Input Format
Input must be formatted in the following manner for each data type:
Character, Graphic: No special formatting, data will be input to field 'as is', but truncated at the length of the bound filed.
Indicator: Data should be formatted as '1' (*On), or '2' (*Off).
Decimal: Data should be formatted in 'human readable' format, such as '123.45', or '-0.99'. Any currency symbol, units, etc., should be omitted.
Date/Time/Timestamp: Data should be formatted in the internal format for the field. The internal format is *ISO by default for all Date/Time/Timestamp fields, but this can be changed by the presence of DATFMT/TIMFMT, and DATSEP/TIMSEP keywords on referenced fields. For example, a *EUR date (1 September 2014) should be formatted as '01-09-2014', and a *USA time (3:30pm) should be formatted as '03:30 PM'.
If input is missing or formatted incorrectly, a default value will be populated for the field.
Input ValidationÂ
If the program needs to accept HTTP input in a different way than described above, or if it needs to simply determine the original HTTP input, the Handler can optionally populate a data structure which will provide this information to the program. This "field inputs" data structure is defined in /COPY member PROFOUNDUI/QRPGLEINC,PUIUNI. If the data structure is passed as a second parameter to the Handler keyword, the Handler will populate it for each READ operation.
For example, a program can determine the 'valid' state for each field and retrieve the original HTTP input using the following code:
Â
Direct Access to HTTP POST Input
In some cases a program may need direct access to the HTTP POST data, such as for reading raw XML or JSON documents sent on the request. When the HTTP request method is POST or PUT, the environment variable 'PUI_UNIVERSAL_INPUT' will be set to a copy of the HTTP input. Text data is encoded in UTF-8 and null-terminated. The CONTENT_LENGTH environment variable can be used to determine the length of binary data. The CONTENT_TYPE variable can be used to determine the type of input. The amount of input that can be read is approximately 14.5MB, any additional text will be truncated.
For example, to read a JSON document from the HTTP POST:
Some documentation pages have recently moved to a new section: Profound AppDev. If you are having trouble finding specific pages, try the documentation search capability or reach out to our Support team!