Use REST services

You can use REST services for communication between components. For example at clean/deploy configuration, the Configuration service is used to clean/update the configuration for a component.

Rule Engine Server REST services

Rule Engine Server provides RESTful API to allow external systems to send REST calls for Rule Engine process operations, and status.

The following REST services are available for Rule Engine Server:

  • RuleEngineProcessRest – used to make a Rule Engine process operation.
  • URL: http://<host>:<port>/resrv-web/api/v1.0/process
  • The following operations are supported on this resource:
    • POST /api/v1.0/process – start a Rule Engine process operation
    • GET /api/v1.0/process/{taskId} – get the status of the process operation
  • RuleEngineStatusRest – used to get the status/clean the created Rule Engine Runtimes
  • URL: http://<host>:<port>/dsclient-web/api/v1.0/extract
  • The following operations are supported:
    • POST – clean the created Rule Engine Runtimes
    • GET – get the status of the created Rule Engine Runtimes

For details about REST services parameters, the Rule Engine Server RESTful API documentation is provided as a Swagger UI that can be found at http://<host>:<port>/resrv-web/apidocs.

All REST services can be tested using the Swagger UI.

Example for RuleEngineProcessRest call

POST request to http://localhost:9081/resrv-web/api/v1.0/process with the body:

{

      "dataFile": "C:\\Axway\\AIS_2.2.0_RC2_R22\\AIS\\Samples\\AIS\\Finance1\\RuleEngine\\data\\IEvent.seq",

      "configurationId": "ais",

      "application": "default",

      "collectionTypeName": "LOAN",

      "collectionTypeVersion": "1"

}

GET request to http://localhost:9081/resrv-web/api/v1.0/process/1 for the response:

{

      "taskId": "1",

      "status": "FINISHED",

      "success": true,

      "collectionName": "LOAN",

      "collectionVersion": "1",

      "reports": [

{

      "name": "dettrans.edi",

      "path": "https://localhost:9081/resrv-web/download/001731ocf3v60imhbibpf746vdojet",

      "type": "DEBUG"

},

{

      "name": "transcnt.edi",

      "path": "https://localhost:9081/resrv-web/download/00186db9epvge2jkri52t5ajoa2ug5",

      "type": "STATISTICS"

},

{

      "name": "cptrg.edi",

      "path": "https://localhost:9081/resrv-web/download/00191a8k4l5oqvqtk412fmqpspsofa",

      "type": "STATISTICS"

},

{

      "name": "detano.edi",

      "path": "https://localhost:9081/resrv-web/download/002104fk0ojhsfkok8l8irkkc1ks631",

      "type": "REJECTS"

}],

      "inputTraceResult": {

      "name": "InputAudit",

      "path": "https://localhost:9081/resrv-web/download/001226098n95o1hr67e27iftqlvbf9",

      "outputType": "INPUT_AUDIT",

      "propertyFile": null

},

      "outputTraceResult": {

      "name": "OutputAudit",

      "path": "https://localhost:9081/resrv-web/download/001154bk2pt1jq0b0sbqjjm1dk9r5a",

      "outputType": "OUTPUT_AUDIT",

      "propertyFile": null

},

      "outputResults": [

{

      "name": "IAS",

      "path": "https://localhost:9081/resrv-web/download/00132qnqe65c4tuej1sj87uev14a6p",

      "outputType": "OUTPUT_EVENT",

      "propertyFile": null

},

{

      "name": "LOCAL",

      "path": "https://localhost:9081/resrv-web/download/0014459henqijnsnae7vgknrttugms",

      "outputType": "OUTPUT_EVENT",

      "propertyFile": null

},

{

      "name": "NULL_FEES",

      "path": "https://localhost:9081/resrv-web/download/00151er1jedkfmvn3fsg4k0ja6kfq0",

      "outputType": "OUTPUT_EVENT",

      "propertyFile": null

},

{

      "name": "SESSION2",

      "path": "https://localhost:9081/resrv-web/download/00165qhlirvdid08qd96sc25du6n0i",

      "outputType": "OUTPUT_EVENT",

      "propertyFile": null

}]

}

The contents of the inputTraceResult can be accessed at https://localhost:9081/resrv-web/download/001226098n95o1hr67e27iftqlvbf9

Example for RuleEngineStatusRest call

GET request to http://localhost:9081/resrv-web/api/v1.0/status for the response:

{

"freeEnginesStatus": [

      {

      "runtimeName": "ARE_1",

      "runtimeState": "CONFIGURED",

      "applicationName": "default",

      "aiConfigId": "aic1",

      "aiConfigVersion": 6

      }

],

"inUseEnginesStatus": [],

"inErrorEnginesStatus": [

      {

      "runtimeName": "ARE_0",

      "runtimeState": "ERR_CONFIG”

      "applicationName": "default",

      "aiConfigId": "aic2",

      "aiConfigVersion": 3

      }

],

"profileName": "",

"processedOperations": 3,

"firstAccess": "2014-09-15 10:05:11",

"lastAccess": "2014-09-15 11:47:32"

}

Designer REST services

The following REST service is available in Designer: Deployment service

Request URL: http://<host>:<port>/designer-web/api/v1.0/deployments

The following operation is supported on this resource:

POST – A POST request on the Deployment service URL creates a deployment package and saves it to <WorkDirectory>/deploymentPackage/. Additionally, it can publish the deployment package to Repository.

For details about REST services parameters, the Designer RESTful API documentation is provided as a Swagger UI that can be found at http://<host>:<port>/designer-web/apidocs.

All REST services can be tested using the Swagger UI.

Administration REST services

The following REST services are available for Administration:

  • User sessions service:
  • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/user/sessions
  • The following operations are supported on this resource:
    • GET – request on this URL starts a list of sessions for a given user name.
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/user/sessions/{userName}
    • DELETE – request on this URL starts a delete of all sessions for a given user name.
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/user/sessions/{userName}
    • DELETE – request on this URL starts a delete of a session for a given user name and session identifier.
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/user/sessions/{userName}/{sessionId}
  • AI configurations service:
  • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/aiConfigurations
  • The following operations are supported on this resource:
    • POST – used for importing the AI configuration and/or internal tables
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/aiConfigurations/{configurationId}
    • GET – used for listing all the AI configurations and internal tables
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/aiConfigurations
    • GET – user for exporting an AI configuration and/or its internal tables
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/aiConfigurations/{configurationId}
    • DELETE – used for cleaning all the AI configurations and internal tables
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/aiConfigurations
    • DELETE – used for cleaning an AI configuration and/or its internal tables or removing an update for it
    • Request URL: http://<host>:<port>/aisadmin-web/api/v1.0/aiConfigurations/{configurationId}

Polling mechanism

For example, for Rule Engine Server file processing, you must do a request to http://<host>:<port>/resrv-web/api/v1.0/process. The request format is:

{

"dataFile": "D:/ais-tools/ruleserver-tools/scanFolder/data/data/IEvent1.seq",

"configurationId": "aic2",

"application": "default",

"collectionTypeName": "LOAN",

"collectionTypeVersion": "1"

}

The request is processed and an asynchronous task is saved in the Repository database. The response contains the task identifier and the url used to check the status of the task. The response is:

{

"taskId": "315166",

"resourceURI": "http://<host>:<port>/resrv-web/api/v1.0/process/315166"

}

The task status can be checked using resourceURI from the response: http://<host>:<port>/resrv-web/api/v1.0/process/315166.

If the task status is IN_PROGRESS, the response is:

{

"taskId": "315166",

"status": "IN_PROGRESS",

"reports": []

}

If the task status is FINISHED, the response is:

{

"taskId": "315166",

"status": "FINISHED",

"success": true,

"reports": [

{

"name": "RuleEngine.log",

"path": "/resrv-web/download/006315174196dvs19ckwwqgql1cjjc0o8znjlvqw",

"type": "DEBUG"

}

],

"collectionVersion": "1",

"reportsGenerated": true,

"outputResults": [

{

"name": "IAS",

"path": "/resrv-web/download/0063151708pvgk7how6iw2ay0k3h9qx1clgbqjaw",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

},

{

"name": "LOCAL",

"path": "/resrv-web/download/006315171ktn9zbog8cufwnr8y6rqlm2rlqilz60",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

},

{

"name": "NULL_FEES",

"path": "/resrv-web/download/006315172hn9j5vil80hpcwbolh9b5ck38aqsl93",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

},

{

"name": "SESSION2",

"path": "/resrv-web/download/006315173nb1vmcnzg1cax3bla15nf3ivohzue42",

"outputType": "OUTPUT_EVENT",

"propertyFile": null

}

],

"inputTraceResult": {

"name": "InputAudit",

"path": "/resrv-web/download/0063151699pqzz07yl790xl2i7316jsrlr1w56h9",

"outputType": "INPUT_AUDIT",

"propertyFile": null

},

"outputTraceResult": {

"name": "OutputAudit",

"path": "/resrv-web/download/0063151682qcy3rteedx1ec0u58krkbvwi03cak6",

"outputType": "OUTPUT_AUDIT",

"propertyFile": null

},

"collectionName": "LOAN"

}

The paths from the response can be used to:

Download the generated files

Send a request to the next component. For example:

{

"dataFile": "http://<host>:<port>/resrv- web/download/0063151682qcy3rteedx1ec0u58krkbvwi03cak6",

"collectionTypeName": "AUDIT_COLLECTION",

"collectionTypeVersion": "1",

"dsComponentName": "DatastoreRuntime"

}

Callback URL mechanism

Using the callback URL mechanism, you can set a callback URL in request(responseUri parameter) that is used to send a POST request with the result when the task is finished. The request is:

{

"dataFile": "D:/ais-tools/ruleserver-tools/scanFolder/data/data/IEvent1.seq",

"configurationId": "aic2",

"application": "default",

"collectionTypeName": "LOAN",

"collectionTypeVersion": "1",

"responseUri": "http://<host>:<port>/resrv-web/api/v1.0/processCallbackURL"

}

Note   In case of a DELETE request, the callback URL can be set in a query string (responseUri) or in the header (X-Response-URI).

Cleanup mechanism

For REST requests that do not specify a destination directory, the generated files, if any, are stored in a temporary directory that is automatically generated . The REST response contains the URLs of the produced files and the client can download them by accessing the URLs.

The client can remove the files after download by performing a DELETE request to the given URLs.

However, if the files are not manually removed, they are automatically cleaned-up after they expire. The generated temporary directories are removed as well when they are empty.

The names of the automatically generated temporary directories follow a specific pattern, specified in Administration > General Settings.

Example of pattern for temporary folders: temp_*_ais. The * character is replaced with the current date and time. In this case, the name of an automatically-generated temporary directory could be: temp_2015_03_14_09_26_53_589_ais.

Rest service response message internationalization

If there is an error for a REST request, the response contains the errorCode parameters, and the message internationalized in the language from the request header. For example:

{

"error": {

"code": "error.inject.dsComponentName.notFound",

"message": {

"lang": "english",

"value": "The component with the name 'DatastoreRuntime' does not exist. ",

"parameters": [

"DatastoreRuntime"

]

}

}

}

After getting this response, you can either use the internationalized message or internationalize the message using errorCode and parameters.

Related Links