[Gtk-sharp-list] Newbee: How to perform a HttpRequest from a GTK# app?

huseyin cakir huseyin.cakir35 at gmail.com
Sun May 16 07:43:57 EDT 2010


Example:  HttpRequest (for example to a RESTful service)
http://huseyincakir.wordpress.com/2010/01/28/mono-c-twitter-api-connections-and-xml/

On Fri, May 14, 2010 at 2:25 PM, Adam Tauno Williams <awilliam at whitemice.org
> wrote:

> On Fri, 14 May 2010, Andy York wrote:
> > Does RESTful Service = Web Service?
>
> Yes, it is essentially RPC over WebDAV.  SOAP & XML-RPC are easier, but
> whatever, some HTTP jockeys really get excited over managing lots of
> low-level stuff themselves.
>
> > straight. Consuming a web service is identical to how you would do it
> > with Windows.Forms. Here is an article that should set you in the right
> > direction
> > (http://www.codeproject.com/KB/webservices/MonoStockInformation.aspx)
> > Here is a simple article on the subject:
> > (http://www.codeproject.com/KB/IP/DownloadClass.aspx?msg=3302029)
>
> +1
>
> Gtk# doesn't have anything to do with RPC, that is all just .NET.
>
> > Last and probably least a simple stupid read/write, this should work but
> > it was just slapped together quickly so your going to want to check it
> over.
> > bool blnEndOfFile = false;
> > HttpWebRequest wr =
> > (HttpWebRequest)HttpWebRequest.Create("http://www.example.com/foobar.xml
> ");
> > HttpWebResponse wsp = (HttpWebResponse)wr.GetResponse();
> > System.IO.Stream s = wsp.GetResponseStream();
> > FileStream fs = new FileStream("C:\Users\UserName\Downloads",
> > FileMode.Create, FileAccess.Write);
> > long lgFileProgress = 0;
> > byte[] b = new byte[2048];
> > while (!blnEndOfFile)
> > {
> >     int n = s.Read(b, 0, b.Length);
> >     if (n > 0)
> >     {
> >         fs.Write(b, 0, n);
> >     }
> >     else
> >     {
> >         blnEndOfFile = true;
> >     }
> > }
> > s.Close();
> > fs.Close();
>
> See!  Using an XML-RPC or SOAP proxy class is *SO* much easier it is
> unbelievable.
>
> With REST you also need to perform POST (they even get that wrong), PUT,
> and DELETE requests.  I'd search the Internet for examples of
> communicating with WebDAV servers via C#/.NET since REST is pretty much
> WebDAV without any of the useful bits.
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20100516/e9aea57e/attachment.html 


More information about the Gtk-sharp-list mailing list