Salesforce

How to consume a REST Webservice from an OpenEdge Client?

« Go Back

Information

 
TitleHow to consume a REST Webservice from an OpenEdge Client?
URL NameHow-to-consume-a-REST-Webservice-from-an-OpenEdge-Client
Article Number000138448
EnvironmentProduct: OpenEdge
Version: 10.2B, 11.x, 12.x
OS: All supported platforms
Other: HTTPClient
Question/Problem Description
How to consume a REST Service from a OpenEdge Client?
How to make a call to REST API from OpenEdge
How to communicate with a RESTFUL service using JSON
How to do HTTP GET and POST in Progress/OpenEdge ABL?
How to GET and POST strings to/from a URL?
Methods for consuming a Webservice from OpenEdge 10.2B
Using the NET HttpClient to consume a WebService
Using the OpenEdge Http client to manipulate JSON strings
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
OpenEdge 10.2B

1. 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.5

In 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:
Workaround
Notes
References to Other Documentation:

OpenEdge Development: Programming Interfaces:  Making HTTP(S) requests from ABL applications
https://docs.progress.com/bundle/openedge-programming-interfaces-122/page/Making-HTTPS-requests-from-ABL-applications.html

Progress Article(s):
Is there an HTTP client for OpenEdge?
 
Keyword Phrase
Last Modified Date9/6/2024 7:45 PM

Powered by