From: Dipper on


Scenario: Windows Mobile C# Compact framework 2.0 or 3.5 Protobuf
object

I need to send an object to a http url (Post). Afterward I will wait
for a response and receive a modified version of the object back. Any
input on how to connect to a http stream and passing in a serialized
object?
From: Peter Foot [MVP] on
For that you can use the System.Net.HttpWebRequest class in System.dll. You
create a new HttpWebRequest using WebRequest.Create with the target Url,
then call GetRequestStream to get a stream you can write your object data
to, then call GetResponse to submit and receive a HttpWebResponse back. This
has a GetResponseStream which allows you to read the returned data. See the
examples here for using GetRequestStream:-
http://msdn.microsoft.com/en-us/library/d4cek6cc.aspx

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - software solutions for a mobile world
In The Hand Ltd - .NET Components for Mobility

"Dipper" <tormorteng(a)gmail.com> wrote in message
news:eecb93a9-515d-432f-8562-fb4a5e0d8ae8(a)k17g2000yqb.googlegroups.com...
>
>
> Scenario: Windows Mobile C# Compact framework 2.0 or 3.5 Protobuf
> object
>
> I need to send an object to a http url (Post). Afterward I will wait
> for a response and receive a modified version of the object back. Any
> input on how to connect to a http stream and passing in a serialized
> object?

From: Dipper on
Thank you for reference to good example. My only issue with it is
that they stream a string object to the httpstream.
ASCIIEncoding encoding = new ASCIIEncoding ();
byte[] byte1 = encoding.GetBytes( (postData);

What would the equivalent be if one would go through serializing a
custom made object with the XMlSerializer?

Regards

On Mar 2, 7:39 pm, "Peter Foot [MVP]" <feedb...(a)inthehand.com> wrote:
> For that you can use the System.Net.HttpWebRequest class in System.dll. You
> create a new HttpWebRequest using WebRequest.Create with the target Url,
> then call GetRequestStream to get a stream you can write your object data
> to, then call GetResponse to submit and receive a HttpWebResponse back. This
> has a GetResponseStream which allows you to read the returned data. See the
> examples here for using GetRequestStream:-http://msdn.microsoft.com/en-us/library/d4cek6cc.aspx
>
> Peter
>
> --
> Peter Foot
> Microsoft Device Application Development MVP
> peterfoot.net | appamundi.com | inthehand.com
> APPA Mundi Ltd - software solutions for a mobile world
> In The Hand Ltd - .NET Components for Mobility
>
> "Dipper" <tormort...(a)gmail.com> wrote in message
>
> news:eecb93a9-515d-432f-8562-fb4a5e0d8ae8(a)k17g2000yqb.googlegroups.com...
>
>
>
> > Scenario: Windows Mobile C# Compact framework 2.0 or 3.5 Protobuf
> > object
>
> > I need to send an object to a http url (Post). Afterward I will wait
> > for a response and receive a modified version of the object back. Any
> > input on how to connect to a http stream and passing in a serialized
> > object?

From: Peter Foot [MVP] on
The XmlSerializer.Serialize method has an overload which takes a Stream
object. You pass the request stream here to write the xml to it.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - software solutions for a mobile world
In The Hand Ltd - .NET Components for Mobility

"Dipper" <tormorteng(a)gmail.com> wrote in message
news:d13cf4ce-93a3-4ce2-9a0d-2eaee1a7fb4f(a)b30g2000yqd.googlegroups.com...
> Thank you for reference to good example. My only issue with it is
> that they stream a string object to the httpstream.
> ASCIIEncoding encoding = new ASCIIEncoding ();
> byte[] byte1 = encoding.GetBytes( (postData);
>
> What would the equivalent be if one would go through serializing a
> custom made object with the XMlSerializer?
>
> Regards
>
> On Mar 2, 7:39 pm, "Peter Foot [MVP]" <feedb...(a)inthehand.com> wrote:
>> For that you can use the System.Net.HttpWebRequest class in System.dll.
>> You
>> create a new HttpWebRequest using WebRequest.Create with the target Url,
>> then call GetRequestStream to get a stream you can write your object data
>> to, then call GetResponse to submit and receive a HttpWebResponse back.
>> This
>> has a GetResponseStream which allows you to read the returned data. See
>> the
>> examples here for using
>> GetRequestStream:-http://msdn.microsoft.com/en-us/library/d4cek6cc.aspx
>>
>> Peter
>>
>> --
>> Peter Foot
>> Microsoft Device Application Development MVP
>> peterfoot.net | appamundi.com | inthehand.com
>> APPA Mundi Ltd - software solutions for a mobile world
>> In The Hand Ltd - .NET Components for Mobility
>>
>> "Dipper" <tormort...(a)gmail.com> wrote in message
>>
>> news:eecb93a9-515d-432f-8562-fb4a5e0d8ae8(a)k17g2000yqb.googlegroups.com...
>>
>>
>>
>> > Scenario: Windows Mobile C# Compact framework 2.0 or 3.5 Protobuf
>> > object
>>
>> > I need to send an object to a http url (Post). Afterward I will wait
>> > for a response and receive a modified version of the object back. Any
>> > input on how to connect to a http stream and passing in a serialized
>> > object?
>