[ServiceModel] Fixes missing xsi xsd attributes
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 10 Dec 2015 11:58:07 +0000 (11:58 +0000)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Mon, 4 Jan 2016 15:42:26 +0000 (15:42 +0000)
While serializing operations with XmlSerializerFormatAttribute,
attributes xmlns:xsi and xmlns:xsd were not added to the message body.

XmlBodyWriter now adds the missing attributes.

Fixes #34413.

mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs

index 9c1df61310afc8a0a3fa858179fe59bc55847ea4..0f881358df53ba2a369eead866e706fe59de4c3b 100644 (file)
@@ -38,6 +38,7 @@ using System.ServiceModel.Channels;
 using System.ServiceModel.Description;
 using System.Text;
 using System.Xml;
+using System.Xml.Schema;
 using System.Xml.Serialization;
 
 namespace System.ServiceModel.Dispatcher
@@ -135,6 +136,11 @@ namespace System.ServiceModel.Dispatcher
 
                        protected override void OnWriteBodyContents (XmlDictionaryWriter writer)
                        {
+                               if (writer.WriteState == WriteState.Element) {
+                                       writer.WriteXmlnsAttribute ("xsi", XmlSchema.InstanceNamespace);
+                                       writer.WriteXmlnsAttribute ("xsd", XmlSchema.Namespace);
+                               }
+
                                serializer.Serialize (writer, body);
                        }
                }