Connecting and providing RESTful Web Services
With the REST protocol different systems can be connected to the REST interface. It works on pure web technologies and on the basis of stateless logic for querying and editing data in systems. It is used in many modern application platforms that allow access and data exchange for external systems via the REST interface.
The OPC Router is able to access and query REST WebServices. Thus almost any system can be connected with REST API and allows to retrieve data from these systems or to transfer data. Via the REST Trigger the OPC Router can also provide REST functions for calling and thus enables the creation of an own REST API for any system which is connected with the available plug-ins.
New: Using the example of weather data from OpenWeatherMap we show the REST Plug-in in action!
That’s how easy it is.
The REST protocol transfer object accesses the resource via endpoints, while the method used indicates allowed interactions.
The method is selected via any given endpoint path. The method can be determined by request parameters. The method result is generated as response. The data in the response field can have any desired format; and is often returned as XML or JSON.
The respective scope of various methods is often documented by Swagger. Call results in XML or JSON can be further processed via XPath and JPath plug-ins.
The REST plug-in uses the standard trigger available in the OPC Router to prompt the transfers.
For direct connection triggering by external systems, the REST plug-in provides an interface for calling REST functions in the OPC router. Thus, the REST trigger serves as a direct call target. Parameters can be passed to the REST call which are used in the connection after the call.
The methods of any given endpoint are read out via Swagger or OpenApi.
All methods are provided in a methods results list, made available as a list of all usable REST Service paths, for convenient selection. Various procedures are supported, among them: GET, PUT, POST und DELETE.
REST Plug-in Application Examples
Data exchange between PLC and REST interface
Systems with REST interface allow you to modify your objects externally by calling REST functions. The objects can represent any entities, depending on which application the system implements. In addition to changes to objects, objects can also be created, queried, or deleted.
To create or modify objects using data from a PLC, the PLC can be connected via OPC UA and the OPC Client plug-in. Which objects can be addressed in the target system can be queried and browsed via the OpenAPI / Swagger function by the OPC router. If, for example, a batch can be created via REST, the PLC must provide all data in OPC data points when the batch is created and trigger the REST call. The data points are then transferred as a JSON packet by REST call and the batch is created as an object.
Create REST API for Zebra Printer
The OPC Router can also accept REST calls via the REST trigger. If several connections with respective REST triggers are created, a REST API / Web API is created. If, for example, a REST API is to be provided for a Zebra label printer to enable other systems to print via webhook (REST Call), a connection is created in which all print data is transferred to an OPC router REST trigger via REST Call. In the connection this data will be inserted into ZPL and sent directly to the Zebra printer with the Zebra Plug-in. In this way, the printer is abstracted and offered in the system structure as a REST Web Service.
Here you will find further information
about OPC Router and Plug-ins.