OneData Support for RESTful Web Services
Data Types
RESTful web services for OneData support all data types supported by OneData except multi-select and BLOB columns. The REST web service supports the CLOB column in the POST web service but not in the GET service.
Displaying and processing columns in RESTful Web Services
The column-level boolean property Hide In Service Layer? is used to enable the visibility of the column in Service Layer and JMS. The default value is false.
OneData enables you to hide unwanted columns while reading or writing data in OneData service call. In the earlier versions, the visibility in both the service layer and display screen was managed by Hide In Display Screen set at column level in conjunction with onedata.webservice.rest.ignore.HideInDisplayCol.In.Schema and onedata.webservice.rest.foreignKeyRelatedDescription.format. OneData has separated the visibility of the column in service layer to use the property Hide In Service Layer and the visibility of the column in the display screen to use the property Hide In Display Screen. The Additonal Qualifier at object level Enable Hide In Service is introduced to maintain backward compatibility with older versions of OneData and to provide a controlled mechanism to migrate from earlier approach to recent approach. Set Hide In Service Layer at column level for all columns in the object and then tag the object's Additonal Qualifier with Enable Hide In Service, to avail the capabilities provided by column level property Hide In Service Layer.
Note:
Consider two data objects, Employee and Department where object Employee refers to a column DEPT_ID in object Department. When the data objects, Employee and Department are created, both will have an additional object level qualifier Enable Hide In Service set. While performing read-write operations on the Employee object, the object level qualifier set on the Employee object is considered and the one set on the object Department is ignored.
Supported Resource Representations
OneData REST services allow you to use XML and JSON resource representations. The REST API request header Content-Type=application/resource type determines if XML or JSON is the REST resource type. The default resource type is xml, change this value to json for JSON REST APIs.
In OneData, both XML and JSON REST APIs support all OneData object types, with the exception of multi-select and supertype subtype structures.
The data types supported in XML and JSON REST APIs are:
Data Type | Payload in XML String Format | Payload in JSON Format |
Boolean | "NRI" : "true" | "NRI" : true |
Char | "Code" : "IND" | "Code" : "IND" |
Date | "DOB" : "11.11.2016" | "DOB" : "11.11.2016" |
Decimal | "CGPA" : "9.82" | "CGPA" : 9.82 |
Numeric | "ID" : "1001" | "ID" : 1001 |
String | "Name" : "John" | "Name" : "John" |
Timestamp | "FlightTime": "01.02.2016 11:11:11.999999999" | "FlightTime": 01.02.2016 11:11:11.999999999 |
Advantages and Limitations of JSON Over XML REST APIs
Being more easy to parse, JSON is generally preferred over the XML resource representation. Compared to XML, the JSON payload is easily and accurately processed under the following conditions:
When no
XML/JSON Element Name exists, multiple entities in an object hierarchy can have identical column names.
Simple tags appear after complex nested tags.
Complex hierarchies with denormalization issues.
When no
returnColumns are specified for conceptual objects, the response to the JSON request maintains the hierarchical structure of the payload format. Whereas the XML output included denormalized data which is difficult to correlate to the payload format.
However, when using JSON REST APIs, consider the following limitations that are not applicable to XML REST APIs. JSON requests do not support:
The exception queue, because
OneData does not support the REST parameter
partialCommit=true.
Service audit columns in the POST response, because the property
onedata.webservice.rest.responseLogLevel is not currently supported.
Prefixing the
XML/JSON Element Name to the object columns. Whereas this is available for XML requests with the use of the
onedata.webservice.rest.objectNamePrefixedInXSD property.