Use OpenEdge.NET for streaming

Posted by onnodehaan on 26-Sep-2018 09:24

Hi guys

I'm investigating how to streaming reports/PDF's from OpenEdge to a REST-service. That REST-service requires me to do streaming, but I can't find any support from streaming with the current HTTP implementation.

I'm wondering if anyone has done this before or if someone can give me some usefull pointers?

Posted by onnodehaan on 07-Oct-2018 13:40

Hi,

I can't use System.NET because our backend also runs on Linux/Unix.

And making calls from the client, by using System.NET, is not desireable because of the tight security measures that are in place nowadays.

But... it turned out that the REST-service that I needed to call, is accepting the request from openedge. I used a Multipart message that contained one binary part, and it worked like a charm!!

So thanks for your time everyone!

All Replies

Posted by Peter Judge on 26-Sep-2018 10:04

Onno,
 
What kind of streaming does the REST-service require?
 
From PASOE you can return a response in HTTP chunks (https://tools.ietf.org/html/rfc2616#page-25) , by writing the output in pieces (so load PDF into a memptr, call Write(get-bytes(m, 1, 1024)) etc .
 
The ABL HTTP client does not send data in chunks. It can consume chunked responses though. It is also not a streaming client since it is synchronous.
 
 
 
 
 

Posted by onnodehaan on 28-Sep-2018 14:26

Hi Peter,

This javascript example show how we would send data to it from postman for example. I'm wondering if i could mimic the same approach in OpenEdge?

Regards, Onno

var http = require("http");

var options = {

 "method": "POST",

 "hostname": [

   "test",

   "test

 ],

 "path": [

   "api",

   "v1",

   "attachments"

 ],

 "headers": {

   "content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",

   "Cache-Control": "no-cache",

   "Postman-Token": "8631da63-55e3-43f0-bdb4-1fee2cfca911"

 }

};

var req = http.request(options, function (res) {

 var chunks = [];

 res.on("data", function (chunk) {

   chunks.push(chunk);

 });

 res.on("end", function () {

   var body = Buffer.concat(chunks);

   console.log(body.toString());

 });

});

req.write("------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"attachment\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"attachment\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");

req.end();

Posted by jquerijero on 03-Oct-2018 15:29

[quote user="onnodehaan"]

Hi guys

I'm investigating how to streaming reports/PDF's from OpenEdge to a REST-service. That REST-service requires me to do streaming, but I can't find any support from streaming with the current HTTP implementation.

I'm wondering if anyone has done this before or if someone can give me some usefull pointers?

[/quote]

Have you looked at System.Net.HttpWebRequest with the SendChunked set to true?

Posted by onnodehaan on 07-Oct-2018 13:40

Hi,

I can't use System.NET because our backend also runs on Linux/Unix.

And making calls from the client, by using System.NET, is not desireable because of the tight security measures that are in place nowadays.

But... it turned out that the REST-service that I needed to call, is accepting the request from openedge. I used a Multipart message that contained one binary part, and it worked like a charm!!

So thanks for your time everyone!

This thread is closed