The DataLayer.REST element gives developers the ability to retrieve information from a web service that uses Representational State Transfer (REST) protocols. The Logi server engine generates an XML rowset from the data returned and developers can use tokens to retrieve records from each column.
We also offer DataLayer.Web Service for use with web services that use the SOAP protocol.
The DataLayer.REST element has the following attributes:
(Required) The ID of a Connection.REST element defined in the _Settings definition. If this value is left blank, the datalayer will use the first connection in the _Settings definition. For clarity, developers are advised to enter an ID here in all cases.
(Required through v10.1.46) Unique element ID.
The portion of the URL specific to the REST-style web service. This value will be appended to the end of the URL specified in the Connection.REST element's UrlHost attribute and may need to begin with a "/". For example,
Connection.REST -> UrlHost = http://local.yahooapis.com
Complete URL to request web service method:
Specifies whether the namespace and schema information that some XML data sources will add to the retrieved data is removed. The default value is False.
Specifies a standard XPath string that will be used to select a set of matching nodes. All of the matching nodes are then used to generate the resulting datalayer.
Beginning in v11.0.727, DataLayer.REST will work with SSL-secured sites.
Read Remote XML Files
DataLayer.REST is also capable of reading the contents of an XML file on a remote web server. Connection.REST is configured in the same way, with the server URL, but the datalayer's UrlPath attribute is configured to include the file name and extension, for example:
and the two URLs are appended together to form the complete URL to the file. The datalayer will retrieve the XML data from the file.
A web service can expose one or more of its methods so that they can be called by developers from an application. Web service methods return XML as a serialized string type. The XML data may require special formatting for use within Logi reporting products. Logi Studio includes an XslTransform element which can be quite useful for converting XML in a datalayer into a format the Logi engine understands.
The information needed to understand a REST web service can be found in the web service's Web Application Description Language (WADL) document. This is the REST equivalent of the SOAP-based web service's WSDL document.
The following example illustrates how to use the DataLayer.REST element:
- Add a DataLayer.REST element to the definition, as shown above, and configure its attributes per the attribute table in the previous section.
When you run your report, the data from the web service should be retrieved into the datalayer. The example above shows Data Table Column elements that have been added to display the data.
When working with web services and data tables, you may not be sure what the column names of the returned data will be; this is a perfect time to use the Add data columns wizard found in Studio. Right-click the datalayer element, then select the options shown above in the pop-up menus. The wizard will interrogate the web service and insert the elements needed to display your data table columns.
For more information, our Web Service Sample Application demonstrates the use of DataLayer.REST.
Beginning in v10.0.299, Studio includes a wizard that can assist you in configuring DataLayer.REST. The wizard assumes that you have already added a Connection.REST element to the _Settings definition and configured it.
As shown above, the wizard can be started by selecting and then right-clicking the parent element under which you want to add the datalayer, and using the context menus to select "Add a REST DataLayer". The wizard opens; use it as follows:
- Select the ID of the Connection.REST element from the drop-down list of available connections. Click Next to continue.
- Enter the Url Path for the web service. Note that you can use tokens here. Click Next to continue.
- Click Finish to insert the datalayer.
- The wizard inserts the datalayer and configure its attributes, as shown above. Other attributes, such as XPath, have to be configured manually.