Hi All,
I am trying to create a sample Web application using the PAS Web Transport and I have a couple of questions.
So far I have a WebHandler class that implements Progress.Web.IWebHandler and I am able to get a basic web request to go through and output a very simple HTML page. You can see the sample below.
So onto my questions:
1.) How can I get POST data if said request was submitted via a form? I see I can get URI data from the URI property on the WebRequest but I am at a loss on how to get anything outside of this. In traditional WebSpeed I would just use get-value but I do not see anything similar to this.
2.) This may be answered in #1 but if a file is uploaded via a form is this something that can be grabbed as well? In traditional WebSpeed you get use the get-binary-data but I am not able to verify this works as of yet so I want to make sure I am going to right directions.
Thanks for you time.
Chris Ebbs
/* SAME WEBHANDLER CLASS */
routine-level on error undo, throw.
class System.WebHandler implements Progress.Web.IWebHandler:
method public integer HandleRequest( ):
def var poRequest as class OpenEdge.Web.WebRequest no-undo.
def var poResponse as class OpenEdge.Web.WebResponse no-undo.
def var poResponseWriter as class OpenEdge.Web.WebResponseWriter no-undo.
poRequest = new OpenEdge.Web.WebRequest().
poResponse = new OpenEdge.Web.WebResponse().
poResponseWriter = new OpenEdge.Web.WebResponseWriter( poResponse ).
poResponse:SetHeader("Content-Type", "text/html").
poResponseWriter:Open().
poResponseWriter:Write('<html><body><h1>This is a test</h1></body></html>').
poResponseWriter:Flush().
poResponseWriter:Close().
delete object poRequest.
delete object poResponse.
delete object poResponseWriter.
return 0.
end method.
end class.
1.) How can I get POST data if said request was submitted via a form? I see I can get URI data from the URI property on the WebRequest but I am at a loss on how to get anything outside of this. In traditional WebSpeed I would just use get-value but I do not see anything similar to this.
2.) This may be answered in #1 but if a file is uploaded via a form is this something that can be grabbed as well? In traditional WebSpeed you get use the get-binary-data but I am not able to verify this works as of yet so I want to make sure I am going to right directions.
For "form" kind of applications, you can consider using "MultipartEntity" which can get the headers, path parameter and the body
oEntityWriter = EntityWriterBuilder:Build(poRequest)
:Writer.
oEntityWriter:Open().
oEntityWriter:Write(poRequest:Entity).
oEntityWriter:Close().
assign oEntity = cast(oEntityWriter:Entity, MultipartEntity)
oPart = oEntity:GetPart(1)
// Gets header
oHeader = oPart:Headers:Get('Content-Disposition':u).
mediaType = oPart:ContentType.
// Gets the Path Parameter
empNum = Integer(poRequest:GetPathParameter("CUSTID")).
// Gets body which is a binary
memptr1 = cast(oPart:Body,ByteBucket):GetBytes().
1.) How can I get POST data if said request was submitted via a form? I see I can get URI data from the URI property on the WebRequest but I am at a loss on how to get anything outside of this. In traditional WebSpeed I would just use get-value but I do not see anything similar to this.
2.) This may be answered in #1 but if a file is uploaded via a form is this something that can be grabbed as well? In traditional WebSpeed you get use the get-binary-data but I am not able to verify this works as of yet so I want to make sure I am going to right directions.
Thanks for all the help, that worked so far. I see now how this works, it would be nice for a form-based entity but for now I can use the API to get around most of the issues.