I have a working Web API that receives a parameter from the https API call and performs a database lookup to get the details realting to that input parameter
The Controller that performs the lookup formats the data items that are defined in a class named Contact and returns the data as Contact
This is the resulting data that successfully arrives back on the calling browser: -
<Contact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<conID>123456</conID>
<conFirstName>John</conFirstName>
<conLastName>Doe</conLastName>
<conCompany>Acme Company</conCompany>
<conEmail>joe.doe@aacme.co.uk</conEmail>
<conTelephone1>01234567890</conTelephone1>
<conTelephone2>07764123456</conTelephone2>
<conTelephone3>02345593202</conTelephone3>
<conContact>John T Doe</conContact>
</Contact>
The header does not get displayed on the browser but it is there.
My question is how do I prevent the output from getting the xmlns data in the first XML element that should just be <contact>
What I have tried:
I have the following code in the Register Sub in WebApiConfig.vb
config.Formatters.XmlFormatter.MediaTypeMappings.Add(
New QueryStringMapping("type", "xml", New MediaTypeHeaderValue("application/xml")))
config.Formatters.XmlFormatter.UseXmlSerializer = True