REST API
1 Using Web Integration Service's REST API
The Configuration and Usage chapters explained how to configure the Web Integration Service server to load a base scenario. This chapter focuses on Web Integration Service's REST API, which enables client applications to participate as first-class citizens in the DDS Global Data Space.
In particular, this chapter describes:
2 API Overview
2.1 Common Operations
Web Integration Service's REST API defines a common set of CRUD-like operations to manipulate DDS entities using HTTP requests. Additionally, Web Integration Service provides operations for sending and receiving data samples using DDS.
Unlike in the common CRUD-like operations, where only XML format is supported, write and read operations can use both XML and JSON format to represent data samples.
2.1.1 Create Operations
All DDS entities can be dynamically created given the name of their parent entities and XML representations. Create operations translate to HTTP POST requests, where:
- The URL identifies the parent entity (e.g., if we are creating a new Publisher, the URL identifies the DomainParticipant it belongs to).
- The XML representation of the entity to be created. That is, the specific tag from that defines the entity to be created (e.g., the
<publisher>
tag if we are creating a new Publisher). For more information on entity tags, see Section 5 of the Configuration Chapter.
2.1.2 Delete Operations
All DDS entities can be dynamically deleted given their name. Delete operations translate to DELETE HTTP requests, where:
- The URL identifies the entity to be deleted (e.g., the URL identifying the Publisher we want to delete).
- The body of the HTTP request is empty.
2.1.3 List Operations
This operation returns a list of all the DDS entities under a specific parent. List operations translate to GET HTTP requests, where:
- The URL identifies the entities to be listed (e.g., all the Publishers under a specific DomainParticipant).
- The body of the HTTP request is empty.
The subsequent HTTP response returns the list of entities in its body.
2.1.5 Write Operation
DataWriters provide an extra operation that allows users to send data samples represented in XML or JSON format. The write operation translates to a POST HTTP request, where:
- The URL identifies the DataWriter that is going to write the sample.
- The body of the HTTP request contains the XML or JSON representation of the sample to be sent.
2.1.6 Read Operation
DataReaders provide an extra operation that allows users to receive sequences of data samples in the corresponding DDS DataReader's cache. The read operation translates to an HTTP GET operation, where:
- The URL identifies the DataReader that performs the read operation.
- Different query strings to customize the read operation.
- The body of the HTTP request is empty.
The body of the subsequent HTTP response contains a sequence of data samples read by the DDS DataReader.
2.2 HTTP Requests
Table 1 lists all the HTTP headers required in HTTP requests. The body of the different HTTP requests that realize the operations defined by the REST API are described in Sections 3 and 4.
Header | Description | Required/Optional |
---|---|---|
Content-Type | Identifies the content type of the body of the HTTP request. Valid values are:
| Required (must be application/dds-web+xml for operations other than write and read). |
Cache-Control | Must be set to none. | Required. |
Content-Length | Length of the body of the HTTP request. | Required (except for the GET and DELETE requests) |
OMG-DDS-API-Key | Key that authorizes the client application for the operation being performed. | Required (if authentication is enabled). |
2.3 HTTP Responses
Table 2 lists the common HTTP response headers. These can be found in every response generated by Web Integration Service, regardless of the success or failure of the operation.
Header | Description |
---|---|
Content-Type | Identifies the content type of the body of the HTTP request. Valid values are:
|
Cache-Control | Must be set to none. |
Content-Length | Length of the body of the HTTP response. |
Date | Timestamp of the HTTP response. |
Table 3 describes the HTTP status codes and response bodies for all the common operations in case of success, whereas Table 4 describes the HTTP responses in case of failure. Note that every response will include a short Reason Phrase indicating the success or failure of the operation.
Operation | Status Code | Response Body |
---|---|---|
Create | 204 | Empty body |
Delete | 204 | Empty body |
List | 200 | XML object representation of the requested listing |
Enable | 204 | Empty body |
Write | 204 | Empty body |
Read | 200 | XML or JSON object representation of the samples read |
Error Kind | Status Code | Response Body |
---|---|---|
Invalid Input | 422 | For application/dds-web+xml requests: For application/dds-web+json requests:
|
Generic server error | 500 | |
DDS error | 500 |
3 Creating, Deleting, Listing, and Updating DDS Entities
Section 2 provided a high-level overview of the different operations that Web Integration Service's REST API provides. This section describes the complete set of operations that can be performed on each DDS entity.
The list of supported DDS entities is divided into two categories: Resource Entities and Application Entities.
3.1 Resource Entities
We use the term resource entities for DDS entities within a Web Integration Service scenario that can be shared across applications. For example, DomainParticipants from different applications can be created with the same QoS Profile. Therefore, resource entities can be treated as templates that can be used in the instantiation of applications and their contained entities.
The list of resource entities includes Types (Table 5), QoS Libraries (Table 6), QoS Profiles (Table 7), and Domain Libraries (Table 8).
3.1.1 Types
The <types>
tag represents a library of types. That is, is a collection of data types specified in XML that can be used across applications.
Operation | Configuration |
---|---|
Create Type | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Available Types | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Type | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
3.1.2 QoS Libraries and QoS Profiles
A QoS Library is a collection of QoS profiles and/or QoS settings—specified in XML format—that can be used across applications.
Operation | Configuration |
---|---|
Create QoS Library | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List QoS Libraries | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Qos Library | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create QoS Profile | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List QoS Profiles | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete QoS Profile | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
3.1.3 Domain Libraries
Domain Libraries provide a way to organize a set of domains that belong to the same system. Domain Libraries can be shared across applications.
Operation | Configuration |
---|---|
Create Domain Library | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List Domain Libraries | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Domain Library | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
3.2 Application Entities
We use the term application entities for all the DDS entities that are instantiated within the context of an Application. For example, in Web Integration Service, DomainParticipants are application entities, since they belong to a specific Application and are instantiated upon creation.
The list of application entities includes Applications (Table 9), DomainParticipants (Table 10), Topics (Table 11), Register Types (Table 12), Publishers (Table 13), Subscribers (Table 14), DataWriters (Table 15), and DataReaders (Table 16).
Operation | Configuration |
---|---|
Create Application | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Applications | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Application (and its contained entities) | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create Domain Participant | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Domain Participants within an Application | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Domain Participant (and its contained entities) | HTTP Verb:DELETE |
URL:
| |
Preconditions:
| |
Enable Domain Participant | HTTP Verb:PUT |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create Topic | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Topics within an DomainParticipant | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Topic | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Register Type | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Registered Types within an DomainParticipant | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Unregister Type | HTTP Verb:DELETE |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create Publisher | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Publishers within a DomainParticipant | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Publisher (and its contained entities) | HTTP Verb:DELETE |
URL:
| |
Preconditions:
| |
Enable Publisher | HTTP Verb:PUT |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create Subscriber | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All Subscribers within a DomainParticipant | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete Subscriber (and its contained entities) | HTTP Verb:DELETE |
URL:
| |
Preconditions:
| |
Enable Subscriber | HTTP Verb:PUT |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create DataWriter | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All DataWriters within a Publisher | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete DataWriter | HTTP Verb:DELETE |
URL:
| |
Preconditions:
| |
Enable DataWriter | HTTP Verb:PUT |
URL:
| |
Preconditions:
|
Operation | Configuration |
---|---|
Create DataReader | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml | |
Example Body:
| |
Preconditions:
| |
List All DataReaders within a Subscriber | HTTP Verb:GET |
URL:
| |
Preconditions:
| |
Delete DataReader | HTTP Verb:DELETE |
URL:
| |
Preconditions:
| |
Enable DataReader | HTTP Verb:PUT |
URL:
| |
Preconditions:
|
4 Writing and Reading Data
Section 3 described all the CRUD-like operations that Web Integration Service's REST API provides. This section focuses on the write and read operations.
Table 17 describes write operation of the DataWriter class. Table 18 describes the read operation of the DataReader class.
Operation | Configuration |
---|---|
Write | HTTP Verb:POST |
URL:
| |
Content-Type:application/dds-web+xml orapplication/dds-web+json | |
Example Body: For Content-Type : application/dds-web+xml : For Content-Type : application/dds-web+json :
| |
Preconditions:
|
Operation | Configuration |
---|---|
Read | HTTP Verb:GET |
URL:
| |
URL Query Parameters
| |
Example Request:
| |
Preconditions:
| |
HTTP Response:
|
As stated above, the write and read operations support both XML and JSON formats to represent the data samples that are sent and received. Sections 4.1 and 4.2 describe how these representations map to the supported data types.
4.1 Write Samples XML and JSON Representation
As described in Table 17, the write operation requires sending an XML or JSON representation of the sample in the body of the POST request. This sample representation is an instantiation of the data type associated with the topic the DataWriter sends. Table 19 describes the representation of a simple ShapeType
sample in both XML and JSON format.
Type Definition | XML Representation | JSON Representation |
---|---|---|
|
|
|
All the different XML tags and JSON members are named after the members they represent. In XML, the value assigned becomes a child of the appropriate XML. In JSON, the value is assigned to the member using JSON's native syntax. Table 20 shows the representation of all the supported data types.
Type Definition | XML Representation | JSON Representation |
---|---|---|
Structs (top level) |
|
|
Structs (nested) |
|
|
Union |
|
|
Arrays (simple members) |
|
|
Arrays (complex members) |
|
|
Sequences (simple members) |
|
|
Sequences (complex members) |
|
|
Shorts |
|
|
Unsigned Shorts |
|
|
Enums |
|
|
Longs |
|
|
Long Longs |
|
|
Unsigned Long Longs |
|
|
Floats |
|
|
Doubles |
|
|
Booleans |
|
|
Strings |
|
|
Octets |
|
|
Chars |
|
|
WChars |
|
|
Long Doubles | Unsupported | Unsupported |
WStrings | Unsupported | Unsupported |
In XML, the parser ignores the root tag's name. As a convention, we use the <data>
tag to name it, but users may choose a different convention (e.g., they can choose to name the top-level tag after the data type that is being set). In JSON, the top-level tag is an object that may contain objects, arrays, and other members.
Unset members are automatically set to zero. As a result, DataReaders will receive a complete sample with all the unset members set to zero. In contrast, invalid members will cause a parsing error, which will trigger the cancellation of the write operation and an error HTTP response.
4.2 Read Samples XML and JSON Representation
A successful read operation generates a response that includes a sequence of samples read in its body. The sequence is represented in XML or JSON format, depending on the value of the sampleFormat
query parameter (if set). Table 18 shows example responses both in XML and JSON format.
Every sample contains a metadata section (i.e., the read sample info) and data section (i.e., the sample data itself). The data section contains the sample itself following the same syntax depicted in Table 20. The metadata section contains the following information for the sample that has been read:
source_timestamp
—Shows the timestamp when the sample was written by a DataWriter.valid_data
—Indicates whether the data sample contains data or if is only used to communicate a change in the instance_state of the instance.instance_handle
—Identifies locally the corresponding instance.instance_state
—Indicates whether or not the samples are from a live DataWriter.sample_state
—Indicates whether or not a sample has ever been read.view_state
—Indicates whether or not an instance is new.