PAS4OE + WEBSPEED + Cookie - Forum - OpenEdge Development - Progress Community
 Forum

PAS4OE + WEBSPEED + Cookie

This question is not answered

Hello,

I am looking for complete examples for using cookies in WebSpeed and PAS for OpenEdge. In ideal I need ABL source code that use cookie, sports database and some instructions how it all deploy in PAS4OE.

I did not find anything like it in the Knowledge Base or documentation

In such an example, I would like to explore this dark side for me )

Is there something like that?

Regards,
Valeriy

All Replies
  • I can give a very quick outline
     
    Your HandleGet() method will (in 11.6.2 and beyond) be generated to look something like the below.
     
    In there you can change the oResponse object y adding cookies. You can also read them off the poRequest object.
     
     
           METHOD OVERRIDE PROTECTED INTEGER HandleGet( INPUT poRequest AS OpenEdge.Web.IWebRequest ):
                
                  DEFINE VARIABLE oResponse AS OpenEdge.Net.HTTP.IHttpResponse NO-UNDO.
            DEFINE VARIABLE oWriter   AS OpenEdge.Web.WebResponseWriter  NO-UNDO.
            DEFINE VARIABLE oBody     AS OpenEdge.Core.String            NO-UNDO.
               
            /* The WebResponse body is a wrapper around an entire HTTP response message.
               It contains a status code and reason; headers; cookies and a message body.
              
               API-level doc for this and related classes can be found at
            ASSIGN
                oResponse            = NEW OpenEdge.Web.WebResponse()
                oResponse:StatusCode = INTEGER(StatusCodeEnum:OK)
                .
            /* This body object can be a string or something else (JsonObject for instance) */              
            ASSIGN
                oBody = NEW OpenEdge.Core.String(
                                 'Hello pjudge'
                               + '~r~n':u   /*CRLF */
                               + 'This message was returned by HandleGet in starnovaHandler.'
                               ).
           
            ASSIGN
                oResponse:Entity        = oBody
                /* HTTP messages require a content type */
                oResponse:ContentType   = 'text/plain':u
                /* ContentLength is good too */
                oResponse:ContentLength = oBody:Size
                .
           
            /* The WebResponseWriter ensures that the status line and
               all headers are writted out before the message body/entity. */
            ASSIGN
                oWriter = NEW WebResponseWriter(oResponse).
            oWriter:Open().
           
            /** HTTP MESSAGE ENTITY APPROACH **/
            /* The Progress.IO.OutputStream Write() methods take multiple overloads, for
               a variety of data types. See the doc for more information. */
            oWriter:Write(oBody:Value).
           
            /* Finish writing the response message */
            oWriter:Close().
           
            /* A response of 0 means that this handler will build the entire response;
               a non-zero value is mapped to a static handler in the webapp's /static/error folder.
               The mappings are maintained in the webapps's WEB-INF/web.xml
               A predefined set of HTTP status codes is provided in the OpenEdge.Net.HTTP.StatusCodeEnum
               enumeration */
            RETURN 0.
           
           END METHOD.
     
      po
     
  • Generally the idea is to have one cookie with a random value act as the key into a database table.  The first article of www.oehive.org/.../ezine2.pdf talks about that.  It makes no use of .Net libraries so if you're on UNIX, it is far more portable.

    Setting a cookie and reading the cookie can be found here (pure 4GL and no .Net stuff ) knowledgebase.progress.com/.../17305

    Scott Augé
    President
    Amduus Information Works, Inc.
    Technical Services for Business and Government
    http://www.amduus.com/cms

  • Just for reference the "Net" in the code sample I sent refers to "Network" (similar to java.net.*). It has nothing to do with Microsoft .NET.
     
  • Ah, my mistake.  Thanks for the heads up.

    Scott Augé
    President
    Amduus Information Works, Inc.
    Technical Services for Business and Government
    http://www.amduus.com/cms

  • It's confusing as anything (and I know, I named it thus) … but no better alternatives  presented themselves …
     
  • Hey Peter, I have to say things are now so much easier than the old wrap-cgi api :)

    Wonder what the difference is between OE.Net.HTTP and OE.Web, other than that I would have been expecting to don't even see the WebResponseWriter and only work with the WebResponse object but that might also be possible so pardon my ignorance ;)

    All in all the sample looks good, wonder though how easy one could migrate from old webspeed api...

  • Wrt

    > >>> have to say things are now so much easier than the old wrap-cgi api

    +1.

  • Wow! Thank you all.

  • OpenEdge.Net.* contains the HTTP client (ie caller) and more general HTTP stuff (like URI's , request and response definitions).
    OpenEdge.Web.* contains the HTTP server-side stuff that's intended to run in PASOE.
     
    They're currently in the same procedure library but that will probably change (we want to make OE.Net.* part of the 'base install' since the ability to call REST/HTTP-based services is so central to many apps).
     
  • All in all the sample looks good, wonder though how easy one could migrate from old webspeed api...

    <marketing-ish hat>
    Well you can run 'classic' WebSpeed apps in PASOE without changes* . The ability to define a handler for a specific URI means that you can incrementally move single services to the newer approach without a big bang.
     
    I think, though, that if you wanted to do a complete change to the newer approach you'd have do a fair amount of manual rewrite (and am happy to be proven wrong :)
     
    * usually