RESTAsyncRequest node
Use the RESTAsyncRequest node with the RESTAsyncResponse node to construct a pair of message flows that interact asynchronously with an external REST API.
- Developer
- Application Integration Suite
- Standard
- Advanced
- Express
- Scale
- Adapter
This topic contains the following sections:
Purpose
You can use a RESTAsyncRequest node in a message flow to issue a REST request to an external REST API, and return control to the flow without waiting for a response. The response is received by a RESTAsyncResponse node, which can be in a separate message flow but must be in the same integration server. The nodes are used as a pair, and correlate responses against the original requests by using a unique identifier, which is specified on both nodes.
The RESTAsyncRequest node uses an imported Swagger document in either JSON or YAML format, which you can import from the toolkit workspace, the file system, or from a URL.
If you have created a REST API from scratch in the IBM® Integration Toolkit, a Swagger document was created for you, which you can import and use with the RESTAsyncRequest node. For more information about creating REST APIs, see Creating a REST API.
The RESTAsyncRequest node handles messages in the following message domains:
- DFDL
- XMLNSC
- JSON
- BLOB
- MIME
- XMLNS
- MRM
The RESTAsyncRequest node is contained in the REST drawer of the palette, and is represented in the IBM Integration Toolkit by the following icon:
Using the RESTAsyncRequest node in a message flow
The RESTAsyncRequest node can be used in a message flow to invoke a REST API. Use this node together with a RESTAsyncResponse node, which handles the response to the request asynchronously. For more information about how to use these nodes, see Interacting asynchronously with REST APIs by using the RESTAsyncRequest and RESTAsyncResponse nodes.
SET OutputLocalEnvironment.Destination.REST.Request.UserContext = 'Some important information';
SET OutputLocalEnvironment.Destination.REST.Request.UserContext.Name.FirstName = 'Fred';
SET OutputLocalEnvironment.Destination.REST.Request.UserContext.Name.Surname = 'Bloggs';
SET OutputLocalEnvironment.Destination.REST.Request.UserContext.MyData.Binary = CAST('A piece of data' AS BLOB CCSID 1208);
OutputLocalEnvironment.Destination.REST.Request.UserContext.mixed
.
To use a Mapping node to
create sub-elements, use user-defined elements or cast xsd:any
and
map to them. For example:To access the user context
data after a RESTAsyncResponse node,
read the value or children of the LocalEnvironment.REST.Response.UserContext
environment
variable.
Behavior of a node that adds a request to a group
When a supported node successfully processes a message for output, it adds the information about the request that was just sent to the group that was most recently created in the message flow. The reply ID that the group expects is determined automatically from the transport, and the folder name is taken from the Folder name attribute.
Overrides
By default, the output node adds the request to the most recently created group. If multiple groups are being constructed in the same thread, a local environment override can be used to specify the group ID of the target group: LocalEnvironment.Destination.GroupScatter.RequestNode.GroupId. Requests can only be added to a group that is in construction in the current message flow thread. An exception is issued if no such group is available.
Transactions
Where a transport is transactional, the message obeys the usual transactional rules for the given transport. However, the group information is updated outside of the scope of the transaction. Therefore, if the transaction and output message are rolled back, the request is still added to the group.
Error
If Add Request to Group is true, and Folder name is blank, a configuration exception is issued. The thread context is used to determine which group to add a request to.
If Add Request to Group is true but no group is in construction in this thread, an exception is issued.
If a group ID override is specified and the ID is invalid, or does not correspond to a group that is in construction in the current thread, an exception is issued.
Terminals and properties
The RESTAsyncRequest node terminals are described in the following table.
Terminal | Description |
---|---|
In | The input terminal that accepts a message for processing by the node. |
Failure | The output terminal to which the message is routed if a failure is detected during processing in the node. |
Out | The output terminal to which the message is routed if it represents successful submission of the REST API request, and if further processing is required within this message flow. |
The following tables describe the node properties. The column headed M indicates whether the property is mandatory (marked with an asterisk on the panel if you must enter a value when no default is defined); the column headed C indicates whether the property is configurable (you can change the value when you add the message flow to the BAR file to deploy it).
The RESTAsyncRequest node Description properties are described in the following table.
Property | M | C | Default | Description |
---|---|---|---|---|
Node name | No | No | The node type, RESTAsyncRequest | The name of the node. |
Short description | No | No | A brief description of the node. | |
Long description | No | No | Text that describes the purpose of the node in the message flow. |
The RESTAsyncRequest node Basic properties are described in the following table.
Property | M | C | Default | Description | mqsiapplybaroverride command property |
---|---|---|---|---|---|
Unique identifier | Yes | Yes | The unique identifier that links a pair of RESTAsyncRequest and RESTAsyncResponse nodes. | asyncResponseCorrelator | |
Definitions file | Yes | No | The name of a file containing the definitions for the REST API that you want to invoke. This file must be a valid Swagger 2.0 document, and can be in either JSON or YAML format. | ||
Operation | Yes | No | The name of the operation in the REST API that you want to invoke. | ||
Security identity | No | Yes | The name of the security identity object that
contains the user ID, password, and API key to be used by the integration
node to authenticate to the REST API. Use the mqsisetdbparms command to create
and configure the security identity object, and to set the user ID,
password, and API key to be accessed by the integration node. The
credentials can be specified in the security identity in any one of
the following combinations:
The default value for this property is an empty string, which signifies that the RESTAsyncRequest node will not attempt to authenticate to the REST API. For more information about REST API security identity support, see mqsisetdbparms command. |
securityIdentity | |
Request timeout (sec) | Yes | Yes | 120 | The time in seconds that the node waits for a response from the REST API. The valid range is 1 through (231)-1. You cannot enter a value that represents an unlimited wait. The timeout might take up to one second longer than the specified value. | timeoutForServer |
Base URL override | No | Yes | The base URL to use when making an HTTP request to the REST API. By default, the base URL from the REST API definitions file is used. | baseURL |
The RESTAsyncRequest node HTTP Settings properties are described in the following table.
Property | M | C | Default | Description | mqsiapplybaroverride command property |
---|---|---|---|---|---|
HTTP(S) proxy location | No | Yes | The proxy server to which requests are sent.
This value must be in the form hostname:port. If the configured proxy server requires
authentication, the credentials must be set by using the mqsisetdbparms command with
the resource name |
httpProxyLocation | |
Follow HTTP(S) redirection | No | No | Cleared | If you select the check box, redirections are followed. If you clear this check box, redirections are not followed. | |
Enable HTTP/1.1 keep-alive | No | Yes | Selected | Use HTTP/1.1 Keep-Alive. | enableKeepAlive |
Use compression | No | Yes | None | This property controls whether the content of
the HTTP request is compressed. You can choose a value from none, gzip, zlib (deflate), and deflate. If the request is compressed,
the Content-Encoding header is set to indicate that the content is
compressed. zlib (deflate) represents RFC 1950 + RFC 1951 combined. deflate represents RFC 1951 only. |
requestCompressionType |
The RESTAsyncRequest node SSL properties are described in the following table.
Property | M | C | Default | Description | mqsiapplybaroverride command property |
---|---|---|---|---|---|
Protocol | No | Yes | TLS | The SSL protocol to use when making an HTTPS request. | protocol |
Allowed SSL ciphers | No | Yes | A comma-separated list of ciphers to use when making an SSL request. The default value of an empty string means use all available ciphers. | allowedCiphers | |
Enable SSL certificate hostname checking | No | Yes | No | This property specifies whether the host name of the server that is receiving the request must match the host name in the SSL certificate. | hostnameChecking |
SSL client authentication key alias | No | Yes | (empty string) | This property specifies an SSL authentication alias for the client-side of an HTTP connection. Taking the default value means that the first appropriate key is chosen for you automatically. | keyAlias |
Enable certificate revocation list checking | No | Yes | Not selected | This property specifies whether CRL checking should be enabled for SSL connections | enableCRLCheck |
The RESTAsyncRequest node Request properties are described in the following table.
Property | M | C | Default | Description |
---|---|---|---|---|
Parameters | No | No | The parameters table displays the current list of parameters for the operation that is selected on the Basic panel. For each parameter shown, you can specify an XPath or ESQL expression in the Expression column, to specify a value (either a literal or a message tree path) for that parameter. Alternatively, the values for parameters can be provided in the LocalEnvironment. | |
Content-Type | No | No | The value of the Content-Type header to send
in the request to the REST API. By default, the RESTAsyncRequest node determines
a Content-Type to use based on the input message. For example, if
the input message contains an XMLNSC message, the Content-Type header
in the request will be application/xml . You can select
a Content-Type from the REST API definitions file, or you can specify
your own Content-Type. |
|
Input body location | Yes | No | $Body | The location in the incoming message tree from which data is retrieved to form the HTTP request body that is sent from the RESTAsyncRequest node to the REST API. The default value, $Body, represents the incoming message body. You can enter any XPath or ESQL expression that defines the location of the message tree to serialize and send to the REST API. |
The RESTAsyncRequest node Response properties are described in the following table.
Property | M | C | Default | Description |
---|---|---|---|---|
Accept | No | No | The value of the Accept header to send in the request to the REST API. By default, the RESTAsyncRequest node sends an accept anything value of */*. You can select an Accept from the REST API definitions file, or you can specify your own Accept. | |
Accept compressed responses by default | No | Yes | Selected | This property specifies whether the request
node handles compressed responses by default. If the request header
does not contain an Accept-Encoding header, and this option is selected,
the node sets the Accept-Encoding header to gzip, deflate ,
and any compressed response that is received is decompressed by the
node. If the message propagated to the RESTAsyncRequest node includes
an Accept-Encoding header, the message flow or client application
should handle any compressed response, in which case this property
has no effect. |
Property | M | C | Default | Description |
---|---|---|---|---|
Events | No | No | None | Events that you have defined for the node are
displayed on this tab. By default, no monitoring events are defined
on any node in a message flow. Use Add, Edit,
and Delete to create, change or delete monitoring
events for the node; see Configuring monitoring event sources by using monitoring properties for details. You can enable and disable events that are shown here by selecting or clearing the Enabled check box. |
Local environment overrides
You can dynamically override set values in the local environment in the same way as setting values in other elements of a message. For more information, see Using local environment variables with REST nodes.