Simple JSON output using PASOE - Forum - OpenEdge Development - Progress Community
 Forum

Simple JSON output using PASOE

This question is answered

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 ?  

Verified Answer
  • {&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
  • When you run this, what results are you seeing?  Have you looked to see if there are any errors in the PASOE logs?

  • 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                                  

  • 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).    

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

    The attached works fine for me. 

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • 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.

  • 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.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • {&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
     
     
     
     
     
     
  • Thanks Peter.  When i apply your suggestion it works.  Leon.