(Originally published on the DataFlex Wiki)
2 of 6
DataFlex provides us with the tools to both consume and create RESTful services.
For simplicity, we are only going to deal here with how to do things in DataFlex version 19.1, or higher. Such things are possible in somewhat earlier versions, but require significantly more work to achieve. If you really need to do such things in earlier versions, post your questions regarding how in the appropriate Data Access support forum. In addition, since JSON is by far the most common (almost to the point of exclusivity) resource representation in use in RESTful web services, we will only discuss that.
The tools in question are the following classes:
- cHttpTransfer, which has been a part of the product since before time began, but which was extended with the HttpVerbAddrRequest method in DataFlex 18.1 (DataFlex 2015), which gave it the capability to employ any HTTP verb, rather than just the GET, POST and PUT of the original, and its sub-classes cJsonHttpTransfer and cXmlHttpTransfer, which allow us to make HTTP requests as the basis for consuming web services
- cJsonObject, introduced in DataFlex 19.0 (DataFlex 2017), which allows us to manipulate JSON data in a painless way when both consuming and creating JSON-based web services
- cWebHttpHandler, introduced in DataFlex 19.1 (DataFlex 2019), which allows us to receive HTTP requests from clients when creating web services
Detail on how to do this, with sample code, is set out in the following articles:
- Consuming RESTful Services in DataFlex
- Creating RESTful Services in DataFlex
- A Simple RESTful Service
- Using the REST Library
2 of 6