REST Acceptor Transport Adaptor
Overview
This document contains a description of the main features of FIXEdge's REST Transport Adaptor (REST TA), as well as common steps required for installation.
Concept
FIXEdge REST adaptor is a REST server that handles REST requests with incoming messages in JSON form, converts them to FIX format and sends them to a given target. The adapter is designed for the generic processing of messages, without lock-in to specific message types.
Depending on the configuration settings, the adaptor can transform incoming message to either a FIX XML message of 'n' type, or map JSON fields into FIX tags. The type of the resulting message should be defined in tag 35.
The JSON message format might look as follows:
'{"35":"D", "1":"12345", "56":"CITIGROUP", ..........}'
The adaptor supports repeating groups and nested repeating groups.
Requests are sent as HTTP POST requests to the following URL: http://<Address>:<ListenPort>/messages
Example of REST request using curl for localhost and listen port 8001:
curl -H "Content-Type: application/json" -X POST -d "{\"35\":\"D\",\"1\":\"USD\",\"386\":[{\"336\":\"ABCD\"}]}" http://localhost:8001/messages
Resulting FIX messages can be optionally validated against FIX dictionaries defined in the engine.properties configuration file.
As a result of a REST request, the adapter should return one of the following HTTP status codes:
- 200 - Success
- 202 - Accepted, returned when a message is successfully received and parsed, but couldn't be delivered to the client in FE
- 400 - HTTP error Bad Request (with JSON content including error message), in case of wrong input message or validation errors
- 404 - HTTP error Not found for requests with the wrong URL
Logging for received and send messages
FIXEdge REST adaptor can be configured to write the following data into separate log file:
- Content of input request
- Resulting FIX messages
- HTTP status returned to the caller
Integration with FIXICC
The adaptor supports the monitoring of its current state with FIXICC. It provides the following monitorable properties:
- number of received messages
- number of sent messages
- number of rejected messages
Description of JSON format for input messages:
- Fields in input JSON message are listed as pairs of "FIXID":"FIXValue".
a JSON message can contain repeating groups represented as follows:
{ "NoRecordsID": [ { "FIXID":"FIXValue", "FIXID":"FIXValue"... }, { "FIXID":"FIXValue", "FIXID":"FIXValue"... } ... ] }
Message Conversion Methods
REST Acceptor TA supports two conversion methods:
- Raw (available since FIXEdge 6.9.0)
a. Adapter accepts any FIX message
b. Adapter routes FIX message to BL - WrapInXmlMessage
- Adapter accepts any JSON
- Adapter creates FIX message 35=n (XML Message)
- Adapter stores received JSON as-is in tag 213 (XmlData)
- Adapter routes FIX message to BL
- NumericTagValueMapping
- Adapter accepts JSON, structured as described in JSON format for input messages section
- Adapter seeks tag-value pair "35":"XYZ" in incoming JSON
- If tag-value pair "35":"XYZ" is not found, or XYZ is not a valid FIX message type, adapter returns an error.
- The adapter creates empty FIX message with MsgType 35=XYZ
- For every tag-value pair in JSON corresponding tags/values are filled in FIX message by Adapter
- Adapter routes FIX message to BL
Examples of input/output messages (pipe symbol stands for SOH symbol):
input (from external system) | output (to BL) | |
---|---|---|
WrapInXmlMessage | FIX: 8=FIX.4.4| 9=168| 35=E| 49=0| 56=RESTAdapter| 34=1| 50=30737| 66=List1| 116=OMS1| 52=20191101-11:11:01.080| 394=3| 68=2| 73=2| 11=0003| 67=1| 100=DSMD| 55=11| 54=1| 38=100| 11=0004| 67=2| 100=DSMD| 55=12|54=2| 38=200| 10=235 | FIX (input message is marked orange): 8=FIX.4.4| 9=259| 35=n| 49=0| 56=0| 34=1| 52=20200317-10:23:55.068| 212=201| 213=8=FIX.4.4| 9=168| 35=E| 49=0| 56=RESTAdapter| 34=1| 50=30737| 66=List1| 116=OMS1| 52=20191101-11:11:01.080| 394=3| 68=2| 73=2| 11=0003| 67=1| 100=DSMD| 55=11| 54=1| 38=100| 11=0004| 67=2| 100=DSMD| 55=12| 54=2| 38=200| 10=235| 10=219 |
NumericTagValueMapping | JSON (the example contains repeating groups): {"66":"List1", "56":"RESTAdapter", "34":"3", "35":"E", "68":"2", "49":"JAVA", "394":"3", "116":"OMS1", "50":"30737", "52":"20150101-01:01:01.080", "73":[{"11":"0003", "55":"MSFT", "67":"1", "54":"1", "100":"DSMD", "38":"100"}, {"11":"0004", "55":"IBM", "67":"2", "54":"2", "100":"DSMD", "38":"200"}]} | FIX: 8=FIX.4.4| 9=184| 35=E| 49=JAVA| 56=RESTAdapter| 34=3| 50=30737| 116=OMS1| 52=20150101-01:01:01.080| 66=List1| 394=3| 68=2| 73=2| 11=0003| 67=1| 100=DSMD| 55=MSFT| 54=1| 38=100| 11=0004| 67=2| 100=DSMD| 55=IBM| 54=2| 38=200| 10=249 |
FIX Message validation
REST Acceptor TA can be configured to validate converted FIX messages. FIX Message validation uses the following default validation options:
- prohibitTagsWithoutValue = true
- verifyDataTagsSequence = true
- verifyTagsValues = true
- prohibitUnknownTags = true
- prohibitDuplicatedTags = true
- verifyRepeatingGroupBounds = true
- checkRequiredGroupFields = true
- allowZeroNumInGroup = false
- ignoreUnknownFields = false
Installation steps
In order to set up REST TA for FIX Edge you need to:
1. Copy the FIXEdge distribution package to the FIX Edge home:
Unpack the content of the distribution package to the FIXEdge root directory, e.g. to C:\FIXEdge.
2. Enable TA to be used by FIXEdge.
In the ‘Transport Layer Section’ of the FIXEdge.properties, add REST TA to the list of supported adapters:
TransportLayer.TransportAdapters = TransportLayer.RestTA
Note: If you use other transport adapters, just add TransportLayer.RestTA to the end of the list:
TransportLayer.TransportAdapters = TransportLayer.SmtpTA, TransportLayer.RestTA
3. Configure the TA.
3.1. Add the REST TA section to the FIXEdge.properties.
A sample set of properties is given below:
TransportLayer.TransportAdapters = TransportLayer.RestTA TransportLayer.RestTA.Description = REST Acceptor TA TransportLayer.RestTA.DllName = bin/rest_acceptor_ta-vc10-MD-x64.dll TransportLayer.RestTA.Type = DLL TransportLayer.RestTA.ClientID = RestAcceptorClient TransportLayer.RestTA.LogCategory = RestAcceptorClient TransportLayer.RestTA.ListenPort = 8001 TransportLayer.RestTA.FIXVersion = FIX50 TransportLayer.RestTA.ConversionMethod = NumericTagValueMapping TransportLayer.RestTA.ValidateFIXMessage = ValidateAndWarn TransportLayer.RestTA.SourceIPAddress = 127.0.0.1
Note: Sample settings could be copied from the RESTAcceptorTA.properties file (in the doc folder of FIXEdge distribution package) to the FIXEdge.properties file.
3.2. Optionally, configure logging for the received and sent messages in a separate log category:
Log.RESTTA.Device = File Log.RESTTA.DebugIsOn = true Log.RESTTA.TraceIsOn = true Log.RESTTA.NoteIsOn = true Log.RESTTA.File.Name = FIXEdge1/log/RESTTA.log
4. Restart FIXEdge to apply the changes.
Routing Messages from REST TA
The REST TA Client can be referred to the business layer (BL) by the ClientID name specified in the FIXEdge.properties file. Below is an example of BL_Config.xml.
<?xml version="1.0" encoding="UTF-8" ?> <!-- FIXEdge - the XML Configuration file $Revision: 1.17.2.7 $ <!DOCTYPE FIXEdge SYSTEM "BusinessLayer.dtd"> --> <FIXEdge> <BusinessLayer> <Rule> <Source> <Client Name="RestAcceptorClient"/> </Source> <Condition> <MatchField Field="35" Value=" D|G|F|n " /> </Condition> <Action> <Send> <FixSession SenderCompID="FIXEDGE" TargetCompID="FIXCLIENT"/> </Send> </Action> </Rule> <DefaultRule> <Action> <DoNothing/> </Action> </DefaultRule> </BusinessLayer> </FIXEdge>
REST TA Configuration Parameters
Configuration of the REST Adaptor contains a list of adaptor properties, HTTP server properties, and log settings:
Property Name | Description | Required | Default Value |
---|---|---|---|
Transport adapter parameters | |||
TransportLayer.RestTA.Description | User-defined description of the Transport Adapter | Y | REST Acceptor TA |
TransportLayer.RestTA.DllName | TA library file name. In case this parameter is not specified, the TransportLayer.RestTA.AdapterId is applied to define the adapter's library by ID | Y |
|
TransportLayer.RestTA.AdapterId | The parameter to define the adapter's library by ID. In case this parameter is not specified, or TransportLayer.RestTA.DllName parameter is specified too, the TransportLayer.RestTA.DllName is applied This parameter is applicable since FIXEdge C++ version 6.14.0 | N | REST_ACCEPTOR |
TransportLayer.RestTA.Type | TA library type | Y | DLL |
TransportLayer.RestTA.ClientID | Transport adaptor Client ID which identifies the source of messages in BL config | Y | |
TransportLayer.RestTA.ListenPort | TCP port number for incoming HTTP connections. Allowed range is 1 - 65535 | N | 8001 |
TransportLayer.RestTA.FIXVersion | FIX version of generated messages:
| N | FIX44 |
TransportLayer.RestTA.ConversionMethod | The method used to convert input messages into FIX format:
| N | NumericTagValueMapping |
TransportLayer.RestTA.ValidateFIXMessage | Enables/disables validation of resulting FIX message:
| N | No |
TransportLayer.RestTA.SourceIPAddress | Provides the ability to filter IP addresses on the REST Acceptor TA. Allows specifying multiple comma-separated IP addresses as well as hostnames. Available since FIXEdge 6.17.0 | N | |
HTTP(S) Server Parameters | |||
TransportLayer.RestTA.Protocol | Security type of connection. Allows user to setup secure or non-secure HTTP connection. Introduced in FIXEdge 6.9.0
| Yes | |
TransportLayer.RestTA.HTTP.timeout | Connection timeout for HTTP connections in seconds. | N | 60 |
TransportLayer.RestTA.HTTP.keepAlive | Enables/disables persistent HTTP connections:
| N | true |
TransportLayer.RestTA.HTTP.maxKeepAliveRequests | Specifies the maximum number of requests allowed during a persistent connection. 0 means unlimited connections. | N | 0 |
TransportLayer.RestTA.HTTP.keepAliveTimeout | Connection timeout for persistent HTTP connections in seconds. | N | 10 |
TransportLayer.RestTA.HTTP.maxThreads | A maximum number of threads processing HTTP requests. The allowed range is 1 – 16. | N | 1 |
TransportLayer.RestTA.HTTPS.PrivateKey | Path to a private key Introduced in FIXEdge 6.9.0 | Conditional. | FIXEdge1/conf/AdminRESTAPI.key |
TransportLayer.RestTA.HTTPS.Certificate | Path to certificate Introduced in FIXEdge 6.9.0 | Conditional. | FIXEdge1/conf/AdminRESTAPI.key |
TransportLayer.RestTA.HTTPS.PrivateKeyPassword | Private key password | Conditional Used when the private key is password-encrypted. | |
TransportLayer.RestTA.AuthHeader | Authentication header (may be used in HTTP mode also) Introduced in FIXEdge 6.9.0 | No | |
TransportLayer.RestTA.AuthValue | Authentication value (may be used in HTTP mode also) Introduced in FIXEdge 6.9.0 | No | |
Logging Parameters | |||
TransportLayer.RestTA.LogCategory | Transport adaptor log category | Y | |
Log.RESTTA.Device | The target device for logging the received and sent messages:
| N | |
Log.RESTTA.File.Name | Filename used to log the received and sent messages | N |
Configuration example
An example of REST Acceptor configuration with the security mode turned on:
TransportLayer.RestTA.Description = RESTAcceptorTA TransportLayer.RestTA.DllName = bin/REST_Acceptor_TA-vc10-MDD-x64.dll TransportLayer.RestTA.Type = DLL TransportLayer.RestTA.ClientID = RestAcceptorClient TransportLayer.RestTA.LogCategory = RestAcceptorClient TransportLayer.RestTA.Protocol = HTTPS TransportLayer.RestTA.HTTPS.PrivateKey = FIXEdge1/conf/AdminRESTAPI.key TransportLayer.RestTA.HTTPS.Certificate = FIXEdge1/conf/AdminRESTAPI.crt TransportLayer.RestTA.ListenPort = 8001 TransportLayer.RestTA.FIXVersion = FIX44 TransportLayer.RestTA.ConversionMethod = NumericTagValueMapping TransportLayer.RestTA.ValidateFIXMessage = ValidateAndWarn TransportLayer.RestTA.AuthHeader = apikey TransportLayer.RestTA.AuthValue = QWERTY0123456789 TransportLayer.RestTA.PrivateKeyPassword = PKEYPASS123