How do I serialize an object (to transfer it wireless)?

M

Magnus

Hi!
In my project I have a Pocket PC that should talk to a Webservice over
WLAN.

In the Pocket PC application, I use an object named Box which has the
following variables:

public class clsBox:IWeblabelPPC.IBox{
#region PrivateVariables
private int boxid;
private int ordernumber;
private int articleid;
private string size;
private int quantity;
private bool partofmixedbox;
private int pallid;
private int qualitysamplessuggested;
private int qualitysamplespicked;
private int boxlagerplatsid;
#endregion

In my app I call a method on the Webservice that should include the
info about the box as a parameter, like CreateBox(BoxInfo).

My question is:
How do I serialize the data about the box and include it as paramter
info in the call to the method on the webservice in the best way?

A) Make my own custom made Serialization method like this example?

public int Serialize(Stream stream)
{
long pos = stream.Position;
BinaryWriter wrt = new BinaryWriter(stream);
wrt.Write(color.ToArgb());
wrt.Write(start.X);
wrt.Write(start.Y);
wrt.Write(end.X);
wrt.Write(end.Y);
return (int)(stream.Position - pos);
}

public static ColorStroke Deserialize(Stream stream)
{
ColorStroke stroke = new ColorStroke();
BinaryReader rdr = new BinaryReader(stream);
stroke.color = Color.FromArgb(rdr.ReadInt32());
int X = rdr.ReadInt32();
int Y = rdr.ReadInt32();
stroke.start = new Point(X, Y);
X = rdr.ReadInt32();
Y = rdr.ReadInt32();
stroke.end = new Point(X, Y);
return stroke;
}

B) Build a datatable or dataset that holds the data.

C) Make the method call like CreateBox(Array BoxInfoIntValues[],
string size, bool partofmixedbox)

D) Make an xml-file

E) Other suggestion?

Since I am a newbie at these things with webservices and wireless,
please feel free to make any comment that you think I should consider,
pro's and cons of the different suggestions et.c.

Best regards /Magnus N
 
G

Guest

You can do any of these things (except probably for D), but IMO, a custom
binary serialization (option A) will be the fastests to transfer and
serialize.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top