Http Communication Protocol - RHIT-XPrize/rhit-xprize-pipeline GitHub Wiki
Java annotators will act as clients to the external annotators, which will act as servers, the two of which will communicate over HTTP.
Most data will be sent in JSON format. These JSON blobs will be un-prettified and written on a single line. The examples below are prettified, and as such are not valid, however for readability we’ve formatted them as such.
- In the global configuration file (written as a JSON object), write down the Annotator’s name and the full internet address that will be used to access it. An example is given below.
- The superclass
HttpAnnotator
usesaddFieldToAnnotation()
to convert from the fields of JSON it receives to usable data. The method only works with primitives, so if you have something more complex in your Annotation you will have to override the method to suit your needs. It is suggested that you still useaddFieldToAnnotation()
to convert primitive fields. - The external Annotator should expect a configuration message once the connection is established.
Each annotator pair will use a set address and port number read in from a JSON configuration file formatted as a list of objects in this form:
{
"annotator_name": {
"address": "123.45.67.89",
"port": 1234
},
"other_annotator_name": {
"address": "123.45.67.80",
"port": 4321
}
}
Standard communications will use a multipart POST
request. The body
of this request will be a sequence of pertinent pieces of data, such
as binary blobs of audio or video along with the JSON-ified CAS
object. The various pieces of data must be agreed upon by both the
sender and receiver, but the CAS will always be transmitted.
The server will then respond with an HTTP Response which, if successful, includes a JSON object with a list of annotations by type, where each of the fields of the goal annotation are specified as the body of the response:
{
"my_string_annotation": [
{
"begin": 0,
"end": 3,
"my_string_field": "bar"
},
{
"begin": 5,
"end": 10,
"my_string_field": "foo"
}
],
"my_int_annotation": [
{
"begin": 12,
"end": 13,
"my_int_field": 5,
"my_other_string_field": "foobar"
}
]
}