WebServices: XML or Binary formatting?

Posts   
 
    
obzekt
User
Posts: 60
Joined: 29-Apr-2004
# Posted on: 09-Jun-2004 18:22:42   

Hello. I'm prototyping an app and have the dilemma on which format to use for returning serialized entities and collections from my WebMethods:

  1. MemoryStream stream = new MemoryStream(); BinaryFormatter fmt = new BinaryFormatter(); fmt.Serialize(stream, obj); string s = System.Convert.ToBase64String(stream.GetBuffer());

  2. string s = String.Empty; if (obj is IEntity2) ((IEntity2)obj).WriteXml(out s); else if (obj is IEntityCollection2) ((IEntityCollection2)obj).WriteXml(out s);

Surprisingly, the binary output seems to be 10-15% larger, but I'm not sure what is faster. What is the forum's experience with a production system?

Otis, what is your suggestion?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39570
Joined: 17-Aug-2003
# Posted on: 09-Jun-2004 19:08:19   

Return an XmlNode, you fill with WriteXml. You can at the client build back the object by passing the XmlNode to the ReadXml() method. simple_smile

Frans Bouma | Lead developer LLBLGen Pro