USING Progress.Json.ObjectModel.JsonObject.
USING Progress.Json.ObjectModel.ObjectModelParser. USING Progress.Lang.Object.USING OpenEdge.Core.WidgetHandle. USING OpenEdge.Core.String.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. DEFINE VARIABLE oEntity AS Object NO-UNDO. DEFINE VARIABLE lcHTML AS LONGCHAR NO-UNDO. DEFINE VARIABLE hXmlDoc AS HANDLE NO-UNDO. oRequest = RequestBuilder:Get('http://localhost:9090/oem/resources') :Request. oResponse = ClientBuilder:Build():Client:Execute(oRequest). oEntity = oResponse:Entity. IF TYPE-OF(oEntity, JsonObject) THEN CAST(oEntity, JsonObject):WriteFile('temp/entity.json', true). ELSE IF TYPE-OF(oEntity, WidgetHandle) THEN DO: hXmlDoc = CAST(oEntity, WidgetHandle):Value. hXmlDoc:save('file', 'temp/entity.xml'). END. ELSE DO: IF TYPE-OF(oEntity, String) THEN lcHTML = CAST(oEntity, String):Value. ELSE lcHTML = oEntity:ToString(). /* Change extension per the Response's ContentType */ CASE oResponse:ContentType: WHEN 'application/json' THEN COPY-LOB lcHTML TO FILE 'temp/entity.json'. WHEN 'text/html' THEN COPY-LOB lcHTML TO FILE 'temp/entity.html'. OTHERWISE COPY-LOB lcHTML TO FILE 'temp/entity.txt'. END CASE. END. |
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.IHttpResponse. USING OpenEdge.Net.HTTP.ClientBuilder. DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO. DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO. oResponse = ClientBuilder:Build():Client:Execute(oRequest). MESSAGE oResponse:StatusCode SKIP oResponse:StatusReason SKIP VIEW-AS ALERT-BOX. |