views:

198

answers:

2

Possible Duplicate:
XmlSerializer: remove unnecessary xsi and xsd namespaces

I'm generating some XML using XMLSerializer and a class marked up with attributes. This XML is sent to a REST web service.

It generates the following XML:

<?xml version="1.0" encoding="utf-8"?>
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
  <first-name>API</first-name>
  <last-name>TestPersonDeleteMe</last-name>
  <title>Delete me</title>
</person>

All would be well, except the web service I'm using doesn't understand the schema stuff and throws a 500 error.

Is there a way to stop XmlSerializer adding 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"' to the person tag?

+1  A: 

if you use custom serializer try this

XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
namespaces.Add(string.Empty, string.Empty);

then add namespaces object to your serializer.

Arseny