Simple JSON output using PASOE

Posted by leonkersten on 15-Oct-2019 15:10

We are in the process of migrating from Transaction server to PASOE.

This simple program works correctly using the Transaction server but does not work in PASOE with the  OpenEdge.Web.CompatibilityHandler

USING Progress.Json.JsonParser from propath. 
USING Progress.Json.ObjectModel.* from propath. 
{ src/web/method/cgidefs.i {1}} 
{ src/web/method/webutils.i {1}} 
{&OUT} "Content-Type: application/json" http-newline http-newline. 
def var demoObject as JsonObject. 
demoObject = new JsonObject(). 
demoObject:Add("Tekst","Demo"). 
demoObject:WriteStream("WebStream",yes,"UTF-8").

What am i doing wrong ?  

Posted by Peter Judge on 15-Oct-2019 16:10

{&OUT} "Content-Type: application/json" http-newline http-newline. 
 
What happens when you change this line to
output-content-type ("application/json":U).
?
 
PASOE "emulates" the CGI part of the Classic agent/server architecture. The output of the latter includes the response status line (written explcitly for PASOE, where the Classic model had it automagically added).
 
output-content-type() ultimately calls output-http-header() which'll add the right response status line.
 
You should be able to see the details of the message being sent back if you turn on UBNet logging in the agentLogEntryTypes . I suspect that there's no status line in your example.
 
Hth,
-- peter
 
 
 
 
 
 

All Replies

Posted by ntwatkins on 15-Oct-2019 15:32

When you run this, what results are you seeing?  Have you looked to see if there are any errors in the PASOE logs?

Posted by leonkersten on 15-Oct-2019 15:41

I get an empty page.

The message in the log file is:

17:40:07.777/60772 [thd-1] ERROR c.p.a.adapters.web.WebOutputStreamer - getStatusCode parsing blank error : streamState= ERROR                                  

Posted by leonkersten on 15-Oct-2019 15:43

When i try to access the URL with wget:           HTTP request sent, awaiting response... 500         2019-10-15 17:43:17 ERROR 500: (no description).    

Posted by Peter Judge on 15-Oct-2019 15:47

What's failing?
 
That code looks OK (in isolation).
 

Posted by Mike Fechner on 15-Oct-2019 15:56

[View:/cfs-file/__key/communityserver-discussions-components-files/19/customwrapper.w:320:240]

The attached works fine for me. 

Posted by leonkersten on 15-Oct-2019 15:57

I do not know what is failing.  When i run the exact code (even  the same .r)  on my transaction server i get the JSON object.  When i run it on PASOE, nothing.    All pages that return HTML code work.  It looks like a problem in sending JSON.

Posted by Mike Fechner on 15-Oct-2019 16:00

My sample from above is a CGI wrapper that successfully returns a JSON object to the WebStream on PASOE. I tried this on 11.7.5 right now. But I'm sure I did similar things on 12 already.

Posted by Peter Judge on 15-Oct-2019 16:10

{&OUT} "Content-Type: application/json" http-newline http-newline. 
 
What happens when you change this line to
output-content-type ("application/json":U).
?
 
PASOE "emulates" the CGI part of the Classic agent/server architecture. The output of the latter includes the response status line (written explcitly for PASOE, where the Classic model had it automagically added).
 
output-content-type() ultimately calls output-http-header() which'll add the right response status line.
 
You should be able to see the details of the message being sent back if you turn on UBNet logging in the agentLogEntryTypes . I suspect that there's no status line in your example.
 
Hth,
-- peter
 
 
 
 
 
 

Posted by leonkersten on 15-Oct-2019 16:18

Thanks Peter.  When i apply your suggestion it works.  Leon.

This thread is closed