[WCF] XmlReader from GetReaderAtBodyContents() should not be missing xmlns-es.
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 20 Apr 2015 07:07:42 +0000 (16:07 +0900)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 24 Apr 2015 05:36:58 +0000 (14:36 +0900)
The namespace declarations existed when the entire Message is read but not
in the partial body contents. They caused regressions when we use
serialization stack from referencesource.

It is possible that more namespaces may be requied, but we will be importing
System.ServiceModel later on and then the issue will go away.
So far we don't want regression as long as they show up in our NUnit tests.

mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs

index ec14a780bb07007b121c0f48379eca8420092253..f67ce5dd8ad5a357f0d1408aec19137c4e16ac62 100644 (file)
@@ -258,9 +258,16 @@ namespace System.ServiceModel.Channels
                                WriteBodyContents (body);
                        }
 
+                       var nt = new NameTable ();
+                       var nsmgr = new XmlNamespaceManager (nt);
+                       nsmgr.AddNamespace ("s", Version.Envelope.Namespace);
+                       nsmgr.AddNamespace ("a", Version.Addressing.Namespace);
+                       var pc = new XmlParserContext (nt, nsmgr, null, XmlSpace.None);
+                       
                        var rs = new XmlReaderSettings ();
                        rs.ConformanceLevel = ConformanceLevel.Auto;
-                       return XmlDictionaryReader.CreateDictionaryReader (XmlReader.Create (new StringReader (sw.ToString ()), rs));
+                       
+                       return XmlDictionaryReader.CreateDictionaryReader (XmlReader.Create (new StringReader (sw.ToString ()), rs, pc));
                }
 
                protected abstract void OnWriteBodyContents (