It is possible you could see a 50% improvement (give or take). I say this, because in SL2 WCF uses XML on the wire, and a byte array would be Base64 encoded so it becomes text - and that effectively doubles the size of the data.
So in SL3 you might see that the binary xml support in WCF is able to actually move the byte array without encoding it into text - and that would save nearly half the byte size, and a bunch of wasted processing to encode/decode the array into text on either side of the wire.
What I haven't had time to explore, is whether the DataContractSerializer has a simple switch to make it use binary XML, because if it does, then I can change MobileFormatter to use the DCS in that mode and that'd shrink the original data size pretty substantially as well - pre-compression.
Sadly,
I don't see a way to fully leverage binary XML.
The
MobileFormatter is a CSLA .NET construct that takes the data from the business
object graph and puts it into another object graph. This other object graph is
basically a DTO graph that contains the data from the business object graph,
but in a form where it can be serialized by the DataContractSerializer. The DTO
graph contains information about the original object types, field values and
references - information necessary to rehydrate a clone of the original
business object graph, and information the DCS doesn't grab by itself.
http://www.lhotka.net/weblog/CSLALightObjectSerialization.aspx
And
that’s all good in my view, because it (within limits) replicates the
behavior of the BinaryFormatter and NetDataContractSerializer from .NET.
I
spent some time looking for the “binary DataContractSerializer”,
but haven’t found it yet. Nor have I found a switch where I can tell the
DCS to use binary XML. I’m a bit puzzled about exactly where/how the
binary XML serialization is occurring – I’d have expected there to
be a “binary XML serializer” or switch on the DCS for this purpose…
Anyway,
the data portal calls MobileFormatter and gets a byte array as a result. That byte
array contains the XML created by the DCS. That’s what is sent over the
wire. So WCF is passing a byte array, not XML (even though the byte array
contains XML). And this means using the binary XML option in WCF simply means
it uses binary to pass the byte array, not XML.
It
is possible (but not guaranteed) that this will save a lot of bytes on the
wire. It is very likely that the byte array is base 64 encoded to ensure it is
valid XML. Base 64 encoding nearly doubles the size of data. So if the binary
XML serialization doesn’t base 64 encode the byte array, it would have a
pretty big impact (perhaps almost 50% less) on the size of the data on the
wire.
But
it won’t actually serialize the object data into binary XML, because that
happens before WCF gets the data…
If
anyone is aware of, or runs across, the serializer or serializer option that is
used for binary XML please let me know.
Rocky
Not sure if this helps but,
The WCF binary xml serializer is created by System.Xml.XmlDictionaryWriter.CreateBinaryWriter: http://msdn.microsoft.com/en-us/library/system.xml.xmldictionarywriter.createbinarywriter.aspx
It conform the the MS Proprietary MC-NBFX stadard: http://msdn.microsoft.com/en-us/library/cc219210(PROT.10).aspx
Blog showing examples of using the MS binary serializer: http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/28/wcf-xmldictionaries.aspx
Agile Delta's EFX format that the wc3 is currently supporting for the standard that has a WCF SDK(not free): http://www.agiledelta.com/product_efx.html
some more info:
http://msdn.microsoft.com/en-us/magazine/ee294456.aspx
From: RockfordLhotka [mailto:cslanet@lhotka.net]
Sent: July-27-09 10:28 AM
To: jaddington@alexandergracie.com
Subject: Re: [CSLA .NET] RE: RE: Silverlight 3 and Binary XML vs.
CompressedProxy
Thanks, I'll take a look at those.
Btw, this was very useful information as I changed the code in
3.8 to enable (by default) the use of binary XML. Thanks!
Rocky
From: Justin
[mailto:cslanet@lhotka.net]
Sent: Friday, July 24, 2009 10:26 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: RE: Silverlight 3 and Binary XML vs.
CompressedProxy
Not sure if this helps but,
The WCF binary xml serializer is created
by System.Xml.XmlDictionaryWriter.CreateBinaryWriter: http://msdn.microsoft.com/en-us/library/system.xml.xmldictionarywriter.createbinarywriter.aspx
It conform the the MS Proprietary MC-NBFX stadard: http://msdn.microsoft.com/en-us/library/cc219210(PROT.10).aspx
Blog showing examples of using the MS binary serializer: http://www.wintellect.com/CS/blogs/jsmith/archive/2006/03/28/wcf-xmldictionaries.aspx
Agile Delta's EFX format that the wc3 is currently supporting for the
standard that has a WCF SDK(not free): http://www.agiledelta.com/product_efx.html
RockfordLhotka:Btw, this was very useful information as I changed the code in 3.8 to enable (by default) the use of binary XML. Thanks!
Awesome! Do you have any estimations or benchmarks of what this new feature will save over the wire? Do you still recommend using compression alongside this?
See this thread for more info:
Copyright (c) Marimer LLC