The Request generator can be used as the first component in a web application pipeline, but it is recommended to use the Page Flow Controller and XForms whenever possible. There are cases where additional data from the request may be required, however, and where the Request generator must be used.
Request Generator
- 1. Introduction
- 2. Configuration
- 3. Request Attributes
- 4. Request Body
- 5. Uploaded Files
1. Introduction
Generators are a special category of processors that have no XML data inputs, only outputs. They are generally used at the top of an XML pipeline to generate XML data from a Java object or other non-XML source.
The Request generator streams XML from the current HTTP request. It can serialize request information including headers, parameters, query strings, user and server information.
2. Configuration
The Request generator takes a mandatory configuration to select which request information to return.
This configuration consists of a series of include
and exclude
elements
containing XPath expressions selecting a number of element from the request tree. Those expressions can
be as complex as any regular XPath 1.0 expression that returns a single node or a node-set. However, it
is recommended to keep those expressions as simple as possible. One known limitation is that it is not
possible to test on the value
element of uploaded files, as well as the content of the
request body.
Sample Configuration:
The full tree is:
Orbeon Forms adds a computed request information item: the request-path
. This is
defined as a concatenation of the servlet-path
and the path-info
. This is
useful because both these are frequently mixed up and often change depending on the application
server or its configuration.
This generator excludes all information items by default. To obtain the whole tree (as shown in the
example above), you must explicitly include /request
:
3. Request Attributes
When the request includes /request/attributes
, the Request generator attempts to retrieve
request attributes. Since those can be any Java objects, as of October 2009 the generator only includes
string values.
4. Request Body
When the request includes /request/body
, the Request generator retrieves the body of the
request sent to the application server. The content of the body is made available as the following data
types:
- If the attribute
stream-type
on theconfig
element is set toxs:anyURI
, an URI is returned as the value of the/request/body
element. - If the attribute
stream-type
on theconfig
element is set toxs:base64Binary
, the content of the request encoded as Base64 is returned as the value of the/request/body
element. - Otherwise, the content of the
/request/body
is set as eitherxs:anyURI
if the request body is large (as set by themax-upload-memory-size
property, by default larger than 10 KB), orxs:base64Binary
if the request body is small.
Examples of configuration:
The resulting data type is always set on the body element, for example:
multipart/form-data
encoding, typically used when uploading files.
In such a case, you should read either only the request body, or only the
request parameters.
5. Uploaded Files
Uploaded files are stored into parameter
elements, like any other
form parameter. The rules for the data type used are the same as for the request
body (see above), the data type depending on the stream-type
attribute and the size of the uploaded files:
The parameter
element for an uploaded file contains the following
elements in addition to the name
and value
elements
use for other parameters:
filename
: stores the file name sent by the user agentcontent-type
: store the media type sent by the user agentcontent-length
: stores the actual size in bytes of the uploaded data
A resulting uploaded file may look as follows:
file:
URL, only that it can be read with
Orbeon Forms's URL generator.