OpenEdge 10.2B1. OpenEdge 10.2B has built in statements for handling SOAP services, but no simple statement for a GET/POST. The
cURL command line tool to consume REST service (
http://curl.haxx.se/download.html)
Example: Using the free test Webserver: '
http://httpbin.org"
curl -H "Content-Type: application/json" -X GET "https://httpbin.org/uuid"
curl -H "Content-Type: application/json" -X GET https://httpbin.org/bytes/512 --output randomdata.txt
curl -H "Content-Type: application/json" -X GET "https://httpbin.org/base64/SFRUUEJJTiBpcyBhd2Vzb21l"
curl -H "Content-Type: application/json" -X GET "http://httpbin.org/basic-auth/user/passwd" --user user:passwd
curl -H "Content-Type: application/json" -X PUT "https://httpbin.org/delay/3"
curl -H "Content-Type: application/json" -X POST "https://httpbin.org/post"
curl -H "Content-Type: application/json" -X DELETE "https://httpbin.org/anything/{anything}"
2. OpenEdge 10.2B has
ABL Sockets which can be used to interact with a REST service. ABL Sockets provide a mechanism to read / write to specific sockets which can be used to build a HTTP post routine, or a routine to handle any other socket based protocol.
For example, attached to this Article is a routine -
http.p from freeframework.org - which demonstrates a GET using socket programming.
Further examples are provided in the following Articles:
3. On Windows Platforms, the .
NET HttpClient (
System.Net.Http.HttpClient class) can be used.
USING System.Net.Http.*.
USING System.Environment.
DEFINE VARIABLE HttpClient AS CLASS System.Net.WebClient.
DEFINE VARIABLE webResponse AS LONGCHAR NO-UNDO.
FIX-CODEPAGE (webResponse) = "UTF-8".
HttpClient = NEW System.Net.WebClient().
HttpClient:Proxy:Credentials = System.Net.CredentialCache:DefaultNetworkCredentials.
webResponse = HttpClient:DownloadString("https://httpbin.org/get").
HttpClient:Dispose().
DELETE OBJECT HttpClient.
MESSAGE STRING(webResponse) SKIP
Environment:VERSION VIEW-AS ALERT-BOX.
The following Article provides example ABL that uses the
System.Net.Http.HttpClient
4.
OpenEdge 10.2B, has no native feature to parse JSON content.
Using JSON as the messaging payload, you will need to able to create and parse JSON from the ABL.
This can be achieved by using a third-party JSON Parser for Progress ABL:
OpenEdge 11.5In OpenEdge 11.5 and later, WebServices can be consumed without using socket programming, with the introduction of the
OpenEdge Http client which facilitates calls to remote RESTful services.
- Built in support for calling REST based webservices are provided in the OpenEdge.Net.pl library
- JSON strings can be manipulated, converted from/to ProDataSets, temp-tables, or temp-table buffer objects, using READ-JSON() and WRITRE-JSON() native methods.
Example:
First ensure the OpenEdge.Net.pl library is in the PROPATH:
PROPATH = PROPATH + ",C:\progress\gui\netlib\OpenEdge.Net.pl".
Simple example using the OpenEdge HTTP Client:
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.IHttpResponse.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.RequestBuilder.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
oRequest = RequestBuilder:Get('https://www.progress.com/'):Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).
MESSAGE
oResponse:StatusCode SKIP
oResponse:StatusReason SKIP
VIEW-AS ALERT-BOX.
Further examples are provided in the following Articles: