I'm having a problem with serializing SOAP, and it would be great to find the answer. Here is a very simplified example:
public void Test() { StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); SoapReflectionImporter importer = new SoapReflectionImporter(); XmlTypeMapping map = importer.ImportTypeMapping(typeof(A)); XmlSerializer serializer = new XmlSerializer(map); serializer.Serialize(writer, new A()); } [Serializable] public class A { public A() { BB = new B(); } public int a; public B BB; } [Serializable] public class B { public int A1 { get; set; } public int A2 { get; set; } }
If I run the Test () method, I get the following exception: System.InvalidOperationException: Token StartElement in state Epilog would result in an invalid XML document.
Would thank for any help.
source share