That's interesting, but I suppose it makes a kind of sense, since the
binary serialization for a DataSet sneakily does XML serialization under
the covers before it can even start writing to the binary stream. That's
unfortunate.


> -----Original Message-----
> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> On Behalf Of franklin gray
> Sent: Thursday, May 02, 2002 3:28 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] HTTP Compression of XML WebServices
>
>
> Joel....look what I have found.  Interesting test results.
>
> All done with a dataset with 20000 rows with 8 columns.
>
> Binary Serialize
> Takes 30 secs and uses about 115 meg memory
>
>     Private Sub Button1_Click(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles Button1.Click
>         Dim F As BinaryFormatter = New BinaryFormatter()
>         Dim F2 As BinaryFormatter = New BinaryFormatter()
>         Dim B() As Byte
>         Dim S As New System.IO.MemoryStream()
>
>         F.Serialize(S, Me.DataSet11)
>         S.Flush()
>         S.Position = 0
>         Dim MyDS As New DataSet()
>         MyDS = F2.Deserialize(S)
>
>         MsgBox(MyDS.GetXml)
>     End Sub
>
>
> GetXML
> Takes about 20 secs and uses about 80 meg memory
>
>     Private Sub Button2_Click(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles Button2.Click
>         Dim MyDS As DataSet
>         MyDS = Me.mUtil.CreateDS(Me.DataSet11.GetXml, False,
> Me.DataSet11.GetXmlSchema)
>         MsgBox(MyDS.GetXml)
>     End Sub
>
>
> WriteXML
> Takes about 20 secs and uses about 80 meg memory.
>
>     Private Sub Button3_Click(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles Button3.Click
>         Dim MyDS As New DataSet()
>         Dim S As New System.IO.MemoryStream()
>         Dim S2 As New System.IO.MemoryStream()
>         Me.DataSet11.WriteXmlSchema(S2)
>         S2.Flush()
>         S2.Position = 0
>         Me.DataSet11.WriteXml(S)
>         S.Flush()
>         S.Position = 0
>
>         MyDS.ReadXmlSchema(S2)
>         MyDS.ReadXml(S)
>         MsgBox(MyDS.GetXml)
>     End Sub
>
> -----Original Message-----
> From: Joel Mueller [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 02, 2002 2:45 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] HTTP Compression of XML WebServices
>
>
> Oh, now this is interesting: If I open up the binary file
> created by the binary serialization of a DataSet in notepad,
> the contents of the file are XML! That's really odd; I know
> for a fact that other types don't produce XML during binary
> serialization. No wonder the size of the uncompressed binary
> is so close to the size of the XML file.
>
>
> > -----Original Message-----
> > From: Joel Mueller [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 02, 2002 2:42 PM
> > To: 'dotnet discussion'
> > Subject: RE: [DOTNET] HTTP Compression of XML WebServices
> >
> >
> > Here's an example for you that does binary serialization of
> a DataSet,
> > compressing the serialized stream on the fly. On my system, the
> > uncompressed XML from the DataSet is 31,253 bytes, the uncompressed
> > binary version of the dataset is 30,804 bytes, and the compressed
> > binary version is 3,841 bytes.
> >
> > using System;
> > using System.IO;
> > using System.Data;
> > using System.Data.SqlClient;
> > using System.Runtime.Serialization;
> > using System.Runtime.Serialization.Formatters.Binary;
> >
> > using NZlib.GZip;
> >
> > class Class1
> > {
> >       [STAThread]
> >       static void Main(string[] args)
> >       {
> >               SqlConnection myConnection = new
> > SqlConnection("server=localhost;trusted_connection=yes;databas
> > e=Northwind");
> >               SqlDataAdapter myAdapter = new
> SqlDataAdapter("SELECT *
> > FROM Products", myConnection);
> >
> >               DataSet ds = new DataSet();
> >               myAdapter.Fill(ds);
> >
> >               Console.WriteLine("DataSet rows: {0}, cols: {1}",
> > ds.Tables[0].Rows.Count, ds.Tables[0].Columns.Count);
> >
> >               StreamWriter xmlOut = File.CreateText("products.xml");
> >               xmlOut.Write(ds.GetXml());
> >               xmlOut.Close();
> >
> >               Console.WriteLine("XML file size: {0:n} bytes", new
> > FileInfo("products.xml").Length);
> >
> >               IFormatter formatter = new BinaryFormatter();
> >               Stream output = new
> > GZipOutputStream(File.Create("products.bin.gz"));
> >               formatter.Serialize(output, ds);
> >               output.Close();
> >
> >               Console.WriteLine("Compressed binary file size: {0:n}
> > bytes", new FileInfo("products.bin.gz").Length);
> >       }
> > }
> >
> >
> >
> > > -----Original Message-----
> > > From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> > > On Behalf Of franklin gray
> > > Sent: Thursday, May 02, 2002 2:02 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [DOTNET] HTTP Compression of XML WebServices
> > >
> > >
> > > oh....well that makes things a little different.  I guess
> I should
> > > have asked about that sooner:-(  Thanks for the info. It
> might come
> > > in very handy.  I am still playing with the binary
> serializtion of a
> > > Dataset because I have noticed that for large datasets,
> it can take
> > > a while to create the dataset from xml.  Does anybody have an
> > > example of a binary serialization of a dataset avaiable?
> > >
> > > -----Original Message-----
> > > From: Marsh, Drew [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, May 02, 2002 1:44 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [DOTNET] HTTP Compression of XML WebServices
> > >
> > >
> > > franklin gray [mailto:[EMAIL PROTECTED]] wrote:
> > >
> > > > by doing this binary serialization of a dataset, would it
> > > be the same
> > > > dataset?  I too do it the way Robert does, by getting
> the xml and
> > > > re-creating it on the client after decryption and
> > > decompression.  The
> > > > problem I have is that I loose the row state.  IE...If
> > > change two rows
> > > > on the client, send the ds xml back to the server, then
> > > recreate the
> > > > DS on the server, I will not have two rows in the
> > Getchanges method,
> > > > I will have a row for every row as an addded row. Would Binary
> > > > serialization would solve this problem?
> > >
> > > Are you using WriteXml or GetXml? If you need to maintain
> rowstate
> > > you need to use WriteXml with XmlWriteMode.DiffGram. If
> you want to
> > > only serialize the *changes*, then you should call GetChanges and
> > > WriteXml the resulting DataSet as a DiffGram.
> > >
> > > HTH,
> > > Drew
> > >
> > > You can read messages from the DOTNET archive, unsubscribe from
> > > DOTNET, or subscribe to other DevelopMentor lists at
> > > http://discuss.develop.com.
> > >
> > > You can read messages from the
> > > DOTNET archive, unsubscribe from DOTNET, or subscribe to other
> > > DevelopMentor lists at http://discuss.develop.com.
> > >
> > >
> >
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or subscribe to other DevelopMentor lists at
> http://discuss.develop.com.
>
> You can read messages from the
> DOTNET archive, unsubscribe from DOTNET, or subscribe to
> other DevelopMentor lists at http://discuss.develop.com.
>
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to