Understanding how to use HttpWebRequest with Progress

Posted by goo on 29-Nov-2016 16:04

11.6.2

Ok, I find my self as a dummy when it comes to work with .Net syntax and how to use System.Net with more when it comes to a class inherits from another.

HttpWebRequest Inherits WebRequest and implements ISerializable.

I am able to use WebRequest, but strugle understanding the use of HttpWebRequest.

i.e - WebRequest

------------------------------------------------------

Using System.Net.*.

def var oReq as class System.Net.WebRequest no-undo.

oReq = WebRequest:Create("http://www.google.com").

This works swell, but I would like to use a CookieContainer, so I need to use HttpWebRequest.

def var oHttpReq as class System.Net.HttpWebRequest no-undo.

oHttpReq = HttpWebRequest:Create("http://www.google.com"). <--- no go, wrong type

But this works:

oHttpReq = CAST( System.Net.HttpWebRequest:Create("http://www.google.com"), System.Net.HttpWebRequest),

Why? and how should I understand that I need to cast it to something it is from start?

Is there any documentation I would need to read to understand how Progress implements this?

All Replies

Posted by Peter Judge on 29-Nov-2016 19:36

The remarks at msdn.microsoft.com/.../system.net.httpwebrequest(v=vs.110).aspx talk about the fact that WebRequest:Create method returns an instance of HttpWebRequest of the URI scheme is http or https (so this is a .NET thing).
 
The example on that page shows
        HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com/");
 
The (HttpWebRequest) part is also a CAST  (with C# syntax).
 
There is a “task map” at community.progress.com/.../1187.openedge-gui-for-net-task-map  which may be useful in general terms. Otherwise translating C# to ABL is just practice and asking here :) ; while its quite close in syntax terms there are some places where the difference will catch you.
 
Also, if you want to provide the whole OEM/OEE page in the web browser control then this is probably the best (and only) way to go.  But per Matt Baker’s point in the other thread, if you want to support limited pieces of functionality then the ABL http client may be better suited.

Posted by goo on 30-Nov-2016 00:30

Thanks Peter, know I have a  understanding of it J
 
//Geir Otto
 
Fra: Peter Judge [mailto:bounce-pjudge@community.progress.com]
Sendt: onsdag 30. november 2016 02.41
Til: TU.OE.Development@community.progress.com
Emne: RE: [Technical Users - OE Development] Understanding how to use HttpWebRequest with Progress
 
Update from Progress Community
 
The remarks at msdn.microsoft.com/.../system.net.httpwebrequest(v=vs.110).aspx talk about the fact that WebRequest:Create method returns an instance of HttpWebRequest of the URI scheme is http or https (so this is a .NET thing).
 
The example on that page shows
        HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com/");
 
The (HttpWebRequest) part is also a CAST  (with C# syntax).
 
There is a “task map” at community.progress.com/.../1187.openedge-gui-for-net-task-map  which may be useful in general terms. Otherwise translating C# to ABL is just practice and asking here :) ; while its quite close in syntax terms there are some places where the difference will catch you.
 
Also, if you want to provide the whole OEM/OEE page in the web browser control then this is probably the best (and only) way to go.  But per Matt Baker’s point in the other thread, if you want to support limited pieces of functionality then the ABL http client may be better suited.

View online

 

You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

Flag this post as spam/abuse.

 

This thread is closed