[Mono-list] Small patch for SoapFormatter

Mike Lipkie mlipkie@hotmail.com
Thu, 23 Jan 2003 23:49:07 -0600


This is a multi-part message in MIME format.

------=_NextPart_000_72a0_3951_55fb
Content-Type: text/plain; format=flowed

I began to look into SoapFormatter and while the code is very good, I 
discovered two problems off the bat:

1) It did not throw an exception if you attempt to serialize a class without 
the attribute class (It just returned non-zero value).

2) The XML created could not be read by the microsoft XMLDOM, there was a 
problem with a missing space between namespace defs.  (It is still valid XML 
so it should be read, but it was not.)

This diff file corrects those problems.

I also noticed something strange.  I create a test application that 
generated a output from a .NET and then from Mono and there are significant 
differences, specifically:

1)  Microsoft output puts the namespace definitions within nodes of the 
output XML.  Mono puts all of them at the top node.  The microsoft way 
causes massive duplication of namespaces.

2)  Microsoft adds a bunch of information to the namespace like version, 
culture, and public key to the namespace for custom classes. Mono just adds 
the class name.  Because of this, you can not transfer information between 
environments using the default SoapFormatter.

Mono Information: 
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/SerializationTestLib/SerializationTestLib"

Microsoft Information:
xmlns:a1="http://schemas.microsoft.com/clr/nsassem/SerializationTestLib/SerializationTestLib%2C%20Version%3D1.0.894.27404%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull"

I have some time and want to update this code but I have some questions:

1) What is the path we want to go down?  Should the code be updated to read 
and generate XML more like .NET to allow for easier interop or should the 
system force the developers to use custom attributes to generate Microsoft 
compatable Soap.  I do not know how other systems generate Soap namespaces.  
If anyone has information on how other systems generate Soap, please let me 
know.

2) now that they are more complete, should the SoapFormatter code be changed 
to used XMLTextWriter and XMLTextReader rather then the current custom 
classes XMLSoapWriter and XMLSoapReader.  They have some custom Soap 
functionality but they could be moved over.

3)  Should the namespaces be setup the same as Microsoft (redundent) or at 
the top of the XML?  I have not had time to discover if Microsoft will load 
the XML if the namespace contains all the extra information like version 
numbers.

4)  I also have not looked into the XMLTextWriter but will it update the XML 
attributes and replace escape characters in the string (i.e. space with 
%20%)?  If not, shoudl this be hard coded in the generation or added to the 
XMLTextWriter?

5)  Finally, I noticed that in the SoapFormatter class, some of the 
properties have been implemented BUT incorrectly (they recurse and blow up). 
  I could fix them but they actually do not do anything.  Should I fix them 
or replace code that throws a NotImplementedException and has a MonoTODO 
attribute.


Thanks,
Mike Lipkie

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail

------=_NextPart_000_72a0_3951_55fb
Content-Type: text/plain; name="ObjectSerializer.diff"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="ObjectSerializer.diff"

Index: ObjectSerializer.cs
===================================================================
RCS file: 
/mono/mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/ObjectSerializer.cs,v
retrieving revision 1.4
diff -u -r1.4 ObjectSerializer.cs
--- ObjectSerializer.cs	19 Oct 2002 00:07:21 -0000	1.4
+++ ObjectSerializer.cs	19 Nov 2002 06:15:56 -0000
@@ -61,7 +61,7 @@
			bld.Append (xmlns);
			bld.Append ("='");
			bld.Append (assemns);
-			bld.Append ("'");
+			bld.Append ("' ");
		    }
		  return bld.ToString();
		}
@@ -344,7 +344,7 @@
				return ObjectIndex;
			}
			else
-				return -15000;
+				throw new SerializationException("Class " + graph.GetType().Name + " is 
not serializable");
		}

		public void BeginWrite() //writes the basic elements of a soap message


------=_NextPart_000_72a0_3951_55fb--