I have been asked to provide the following XML document from an http endpoint, exactly like:-
<?xml version="1.0" encoding="utf-8"?>
<XMLFile xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SalesOrders>
...
</SalesOrders>
However Web API spits out
<?xml version="1.0" encoding="utf-8"?>
<XMLFile xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.datacontract.org/2004/07/White.Label.Ordering.Infrastructure.Data.Queries.Export">
<SalesOrders>
...
</SalesOrders>
I have google around and tried various fixes but to no avail, my model looks like
[DataContract]
public class XMLFile
{
[DataMember]
public List<SalesOrder> SalesOrders { get; set; }
}
[DataContract]
public class SalesOrder
{
[DataMember(Order = 1)]
public string OrderNumber { get; set; }
}
and my set up lools like this
public static void Register(HttpConfiguration config)
{
config.Formatters.XmlFormatter.WriterSettings.OmitXmlDeclaration = false;
...
}
How do I remove xmlns:i
and xmlns
and replace with xmlns:xsd
and xmlns:xsi
?
I know this is a bad question as it shouldn't matter but my consuming client is barfing.