Infine, ho trovato la soluzione. Ho appena creato un CustomXmlFormatter per rimuovere lo spazio dei nomi dall'elemento root.
public class IgnoreNamespacesXmlMediaTypeFormatter : XmlMediaTypeFormatter
{
public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
{
try
{
var task = Task.Factory.StartNew(() =>
{
var xns = new XmlSerializerNamespaces();
var serializer = new XmlSerializer(type);
xns.Add(string.Empty, string.Empty);
serializer.Serialize(writeStream, value, xns);
});
return task;
}
catch (Exception)
{
return base.WriteToStreamAsync(type, value, writeStream, content, transportContext);
}
}
}
fonte
2013-05-03 07:35:58
Pubblica la tua soluzione come risposta. Non nella domanda. – arulmr
Grazie arulmr. Per favore continua a modificare i miei post. Questo sarebbe molto utile. –