Which .NET class for HTTP communication?

Which .NET class for HTTP communication?

am 24.10.2007 23:58:23 von Lamont Sanford

Hi,

I'm designing a client application that communicates with a server via HTTP.
The mechanism is fairly simple:

1) Create an XML-formatted string containing the data to send.
2) Send the data to the server via HTTP using a "POST" method.
3) Wait for the server to return XML-formatted data and then process that
data.

What class should I use to execute the HTTP request? I searched MSDN and
came across HttpWebRequest. It looks pretty straight-forward but I just want
to make sure I'm on the right track before I begin.

A couple of other requirements worth mentioning:

a) I need the request to take place in an asynchronous manner.
b) When the amount of data contained in the POST is large, I'd like to be
able to show the user a progress bar and a message stating something to the
effect of "500,000 of 600,000 bytes sent". Is there anyway to get hold of
that status/progress information while the request is in progress?

Thank YOU.

Re: Which .NET class for HTTP communication?

am 25.10.2007 09:49:46 von MR. Arnold

"Lamont Sanford" wrote in message
news:tdWdndE9MJRiIoLanZ2dnUVZ_h2pnZ2d@giganews.com...
> Hi,
>
> I'm designing a client application that communicates with a server via
> HTTP. The mechanism is fairly simple:
>
> 1) Create an XML-formatted string containing the data to send.
> 2) Send the data to the server via HTTP using a "POST" method.
> 3) Wait for the server to return XML-formatted data and then process that
> data.
>
> What class should I use to execute the HTTP request? I searched MSDN and
> came across HttpWebRequest. It looks pretty straight-forward but I just
> want to make sure I'm on the right track before I begin.
>
> A couple of other requirements worth mentioning:
>
> a) I need the request to take place in an asynchronous manner.
> b) When the amount of data contained in the POST is large, I'd like to be
> able to show the user a progress bar and a message stating something to
> the effect of "500,000 of 600,000 bytes sent". Is there anyway to get hold
> of that status/progress information while the request is in progress?
>
http://www.w3.org/TR/XMLHttpRequest/

The XMLHTTPReqquest works asynchronous. Maybe, you should get the length of
the string, do a Transmission started time, Transmission ended time and
(length) of string sent message.

Here is some stuff on

http://www.developerfusion.co.uk/show/4654/

I am sure if you search Google, you'll find more stuff on the how to(s) and
code examples. This is not a new wheel that you're working with and should
be easy to find examples. The CodeProject is a good place to look for code
examples.

Re: Which .NET class for HTTP communication?

am 25.10.2007 12:50:19 von newsgroups_remove

Hello,

from a windows client application, use the HttpWebRequest class.

It has BeginGetRequestStream/EndGetRequestStream,
BeginGetResponse/EndGetResponse methods.

Once you acquired the request stream, you can use the BeginWrite/EndWrite
methods of the stream to send packets of data. Same with the resposne.

This way you can display a progressbar to the user.

Kind regards,
Henning Krause


"Lamont Sanford" wrote in message
news:tdWdndE9MJRiIoLanZ2dnUVZ_h2pnZ2d@giganews.com...
> Hi,
>
> I'm designing a client application that communicates with a server via
> HTTP. The mechanism is fairly simple:
>
> 1) Create an XML-formatted string containing the data to send.
> 2) Send the data to the server via HTTP using a "POST" method.
> 3) Wait for the server to return XML-formatted data and then process that
> data.
>
> What class should I use to execute the HTTP request? I searched MSDN and
> came across HttpWebRequest. It looks pretty straight-forward but I just
> want to make sure I'm on the right track before I begin.
>
> A couple of other requirements worth mentioning:
>
> a) I need the request to take place in an asynchronous manner.
> b) When the amount of data contained in the POST is large, I'd like to be
> able to show the user a progress bar and a message stating something to
> the effect of "500,000 of 600,000 bytes sent". Is there anyway to get hold
> of that status/progress information while the request is in progress?
>
> Thank YOU.
>
>
>

Re: Which .NET class for HTTP communication?

am 25.10.2007 15:36:24 von RAD

On Wed, 24 Oct 2007 16:58:23 -0500, "Lamont Sanford"
wrote:

>Hi,
>
>I'm designing a client application that communicates with a server via HTTP.
>The mechanism is fairly simple:
>
>1) Create an XML-formatted string containing the data to send.
>2) Send the data to the server via HTTP using a "POST" method.
>3) Wait for the server to return XML-formatted data and then process that
>data.
>
>What class should I use to execute the HTTP request? I searched MSDN and
>came across HttpWebRequest. It looks pretty straight-forward but I just want
>to make sure I'm on the right track before I begin.
>
>A couple of other requirements worth mentioning:
>
>a) I need the request to take place in an asynchronous manner.
>b) When the amount of data contained in the POST is large, I'd like to be
>able to show the user a progress bar and a message stating something to the
>effect of "500,000 of 600,000 bytes sent". Is there anyway to get hold of
>that status/progress information while the request is in progress?
>
>Thank YOU.
>
>

I think you might want to take a look at System.Net.WebClient. It does
everything you want perfectly

1) Has an UploadDataAsync method that allows you to upload data
asyncrhonously
2) Has an UploadProgressChanged event that allows you to determine how
much data has been uploaded

--
http://bytes.thinkersroom.com