4.2.5.15. Http Client Gateway Out
With an Http Client Gateway Out, outgoing messages are sent using a HTTP(s) connection.
All the user defined metadatas defined in the messages are passed in the context of the new message.
The specific settings are:
Configuration file |
If you fill it, only this file is used for the configuration. |
Variables |
Allow you to create variables with the response of the call. |
Authentication Type |
You can select from (Basic, Digest, Ntlm, Any, Cert, Form, OAuth 1a, OAuth 2.0 with Bearer, OAuth 2.0 with Credentials) depend on the server response. |
Login url |
If authentication method is (Form, OAuth 2.0 with Credentials). |
Username |
Username used for (Basic, Digest, Ntlm, Any) authentications. For Ntlm authentication, the username can be prepended by the domain (domain/username). |
Password |
Password used for (Basic, Digest, Ntlm, Any) authentications. |
Preemptive Authentication |
Allows to send authentication information with the first http request (to avoid making a second request). |
Trust Level |
The trust level defines the level of security used in the SSL handshake. Relax = No certificate verification. The default is Standard. |
Valid HTTP return code |
Comma separated list of expected return Http code. |
Certificate Alias |
Alias of an existing key certificate. |
Login URL |
If authentication method is (Form, OAuth 2.0 with Credentials). |
Http Headers |
You can add specific http header(s). |
Form Fields |
When using (Form, OAuth 2.0 with Credentials) authentication, you can add specific authentication form fields to the authentication call. |
Grant Type |
You can select (Client Credentials, Password, Other). Client Credentials (Scope, Username, Password). |
ContentType |
You can select (application/json, FORM_URLENCODED). |
OAuth1 Signature Method |
If OAuth 1a authentication is used, this allows select the signature algorithm to use. Note that if SHA1withRSA is used, a Key alias must be selected. |
OAuth1 Consumer Key |
If OAuth 1a authentication is used, this allows defining the consumer key. This is mandatory. |
OAuth1 Consumer Secret |
If OAuth 1a authentication is used, this allows defining the consumer secret. This is optional. |
OAuth1 Token |
If OAuth 1a authentication is used, this allows defining the token. This is mandatory. |
OAuth1 Token Secret |
If OAuth 1a authentication is used, this allows defining the token secret. This is optional. |
OAuth1 Key Alias |
If SHA1withRSA is used, a Key alias must be selected. |
OAuth1 Realm |
The realm value is a string, generally assigned by the origin server, which may have additional semantics specific to the authentication scheme. |
Bearer |
If OAuth 2.0 with Bearer authentication is used, this allows selecting the OAUTH bearer token to use. |
Calls |
In this section you define one or multiple API calls. |
Name |
Name of a call, used in the next step to go to another call. |
HTTP method |
You can specify the http method to call. |
URL |
URL to call to create a message. |
Use the global authentication |
When enabled the call will be done using the global authentication defined. |
Content |
Content to send, for Gateway out, if no content, we send the message. |
Timeout |
Timeout for connection in milliseconds. Must be between 10000 and 240000. |
Post Action |
In a call you can create a Post Action, to do something with the response of your request. |
Condition |
Condition of the creation of the message. |
Response FileName |
Allow you to define a FileName for the new message. |
Set Metadatas |
Allow you to create metadata in the Babelway context. |
Connected Gateways |
Connected Gateways to send the message. |
Next Step |
Name of the next call to run after this one. |
Wait |
Wait time before the execution of the post action. |
Validate |
Allow you to validate the content of the call response. |
Error Message |
The error message that will be generated in Babelway when the Validate fails. |
Retry Strategy |
Allows you to determine what to do if call to remote server fails. If 'No retry' is chosen, the message will be put immediately in error. Other values allow to make some retries before setting the message in error.
|
Maximum allowed senders |
Maximum number of threads that may send messages in parallel for this gateway (from the same Babelway server). |
Main Information
What is the benefit of using the new HTTP Client "Gateway Out" VS old deprecated HTTP Client "Gateway Out" ?
- The new HTTP Client "Gateway Out" allows to chain multiple HTTP calls.
- For each call the user can manipulate and store part(s) or all of the received response information of the current call to be used in the second call if needed based on the HTTP call specification to be implemented.
- The new HTTP Client "Gateway Out" supports scripting language.
Expression
The below print screen shows the expression which the user can select one of the (Constant, Script, Metadata) values, as shown below.
Constant : When selected the user will provide a static text that will be used as a value in this field.
Script : When selected the user will provide a script code which its result will be used in this field to achieve the user logic in this section.
Note:
- For security reasons we use a black box to run the Javascript code and it does not contain many libraries.
- The Script engine is fully compatible with ECMAScript 5.1.
Script Functions
The "HttpClientFunctions" class have the below functions defined that can be used in the Javascript code
- HttpClientFunctions.HmacMD5(String data, String key, Boolean base64Encode)
- HttpClientFunctions.HmacSHA1(String data, String key, Boolean base64Encode)
- HttpClientFunctions.HmacSHA256(String data, String key, Boolean base64Encode)
- HttpClientFunctions.HmacSHA512(String data, String key, Boolean base64Encode)
- HttpClientFunctions.base64Encode(String toEncode)
- HttpClientFunctions.base64Decode(String toDecode)
- HttpClientFunctions.rsaEncrypt(String toEncrypt, String publicKeyAlias)
- HttpClientFunctions.xmlToJson(String data)
The below example shows the use of the HmacSHA256() function from the "HttpClientFunctions" class which will generate the base64 value of the HmacSHA256 of "message" with the key "secret", as shown below.
HttpClientFunctions.HmacSHA256('message','secret',true);
Metadata : When selected the user will provide a metadata name between curly bracket like for example {MetadataName}, This can be a system metadata which is generated in the current channel only because the system metadata is not propagated from one channel to the other, or by selecting a user defined metadata which is generated from the current channel or generated from any previous channel(s) because the user defined metadata is propagated from one channel to the other.
File section
You can download and upload the configuration in XML format.
- Download the current saved configuration, After configuring HTTP Client "Gateway Out" and testing it successfully you can download the current configuration which is saved in XML format.
- Upload the configuration in XML format, This will override the current configuration of the gateway by the provided configuration in the uploaded XML file.
Note: The download button will only download the saved configuration for the gateway, So if you have done some changes to the gateway which is not saved then all of the unsaved information will not be provided in the downloaded XML file.
Global information section
Scripting language is the scrip language used when the "Script" type is selected and the suported scripting language is JavaScript.
Variables
Allow the user to create variables which can be used in a different calls in this gateway when the expression type of "Script" is selected the result of the script will be used, as shown below.
Already defined variables (system variables)
By default Babelway will create the below system variables for each call and there values can be used when selecting the expression of type "Script".
- loginResponseContent : The body of the login response, save as text.
- loginResponseContentBytes : The body of the login response save as byte.
- loginResponseHeaders : The headers of the login response saved as key-value pairs, To get the value of the login response header write loginResponseHeaders.get("header_name")
- loginResponseCode : The status code of the login response.
- responseContent : The body of the response save as text.
- responseContentBytes : The body of the response save as byte.
- messageContent : The content of the message out save as text.
- messageContentBytes : The content of the message out save as byte.
- responseHeaders : The headers of the response saved as key-value pairs, To get the value of the response header write responseHeaders.get("header_name")
- responseCode : The status code of the response.
- responseCookies: The cookies of the response saved as key-value pairs. To get the value of a cookies, write responseCookies.get('sessionId');
Note:
- The response of the call is saved in the script system variable "responseContent" which can be used in the "Post Action" section.
- The expression of type "Script" is case sensitive and you will need to make sure when using the above variables to work properly to provide them using the correct case sensitive as mentioned above.
- For each call the old system variables will be overridden with the new response of the new call, So if you want to use the old system variable in other call(s) then you can save th old system variable in a user variable in the "Post Action - Validate" section.
Global Authentication and call Authentication sections
When a global authentication is defined then it can be used in the calls where the "Use the global authentication" option is enabled, as shown below.
In case for a specific call or calls you will need to use different authentication then you can create the needed authentication type from the "Authentication" section of each call, as shown below.
In case the call will not have any authentications then just make sure to disable the authentication for this call, as shown below.
Note: When using the call authentication of type "OAuth2.0 With Credentials" then you can extract the token from the authentication response and save the token in a metadata which will be used in the "Authorization" header of the call, This can be done by using the "loginResponseContent" variable and set the expression type to "Script", as shown below.
JSON.parse(loginResponseContent).access_token
Calls section
In this section you can create one call or more than one call to connect to a server receiver or send data based on the logic you want to achieve, as shown below.
Name : This is the name of the call which is mandatory and also this name will be used in the "Post Action - Next Step" section when there are more than one call defined and each call is linked to the other call.
Content : This is for the "Gateway Out" only and if this is empty then we will use the output message from this channel.
Wait : How long the to wait before execute the call, The default is 0 second.
Timeout : Timeout for connection in milliseconds which is by default 90 seconds.
Valid HTTP return code : Comma separated list of expected return HTTP code which evaluates the response HTTP code in the header, If the return code is not in the list, the message is set in error, The default is '200,201,202,204,205'.
Post Action - Validate section
The validate section will allow us to validate the call and generate some user defined variables and user defined metadata to be used in other call(s) or channel(s).
Validate Condition : Allows you to validate the call and the call will be valid when the implemented condition result is true and when the result of condition is false the message will fail in error.
Error Message : When the result of the condition above is false the message will fail in error and the error message will be used from this field in the message details.
Variables : Allow you to create variables to be able to use in the calls in this gateway where supported.
Set metadatas : Allow you to create user defined metadata to be able to use in the calls in this gateway where supported and also will be sent the channel(s) when the "Connected Gateways" option is implemented in the "Post Action - Create Message" section.
Post Action - Create message section
In order to send the received response body from the current HTTP Client "Gateway Out" to the next channel(s), It is a must to use "Script" expression with the value of "responseContent" in the "Content" which will be created by default, as shown below.
Note: You can change the "responseContent" with any other system variables and also you can some manipulation to only extract a part of the received response or even do other manipulation to achieve your request.
Condition : Allows you to create a condition to create a message only when the result of the condition is true so only for specific calls the message will be created.
Response FileName : Allow you to define the FileName for the new message created, If this is empty then the default is "httpresponse.txt".
Set metadatas : Allow you to create user defined metadata to be sent the channel(s) when the "Connected Gateways" option is implemented.
The most important is that all of the user defined metadata created in the "Post Action - Validation" section from all of the previous calls including this call will be sent to the next channel(s) and only the user defined metadata created in this "Post Action - Creat Message" section will be sent to the next channel(s).
Connected Gateways : One or several gateways to receive the created message in this section.
User Metadata Transfer Strategy : The strategy that will be used to transfer the user metadata to the new message created in the connected gateways.
Post Action - Next Step section
In order to be able to do multiple calls you will need to provide the second call name exactly in the "Next step" as you have already defined the call name in the "Name" field to be able to execute the second call after this call complete.
If the "Next step" has a type the message will fail in error and when it is empty the execution will end and not other calls will be executed.
Wait : How long the to wait before execute the call, The default is 0 second.
Babelway Message Metadata section
Allow you to update the "User comment" and "Gateway out message key" when the gateway execution is completed.
User comment metadata : Allow you to define the "User comment" of the current message, The value will be trimmed after 4096 characters.
Gateway (In/Out) Message Key : Allow you to define the "Gateway out message key" of the current message, The value will be trimmed after 100 characters.
Retry options
Retry Strategy : Allows you to determine what to do if call to remote server fails. If 'No retry' is chosen, the message will be put immediately in error. Other values allow to make some retries before setting the message in error.
Maximum allowed senders : Maximum number of threads that may send messages in parallel for this gateway (from the same Babelway server).
If you want to benefit from maximum speed, leave this field empty. Only use if the receiver can not receive messages quickly enough.
Message details Call log
To see the complete call log for each call which will help in investigation from the monitoring message details download the "httpClientGatewayFlowOut" ZIP file from the "Files" section.
For security reasons we will not log the "Authorization" header.
Note:
- In Babelway, we're using the standard Java version of REGEX, and it's the same used all over the system.
- If there is a file name provided in the "Message In" or "Message Out" which contain ~ tilde character, All browser based on Chromium will replace the ~ tilde character by the _ underscore character when you try to download the file from the Babelway interface, For more details you can check this link https://bugs.chromium.org/p/chromium/issues/detail?id=479419
- The maximum file size accepted by this gateway is 100/250 MB.