User1536465747 posted
Hello,
I have the following classes to be serialized:
[XmlType(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public class Envelope
{
public Envelope() { }
public Body Body { get; set; }
}
[XmlType(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public class Body
{
public Body() { }
public InfoDetails infoDetails { get; set; }
}
When I serialize those classes like following:
var myNamespaces = new XmlSerializerNamespaces();
myNamespaces.Add("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
//-- another code here
mySerializer.Serialize(myWriter, envelope, myNamespaces);
I end up with an XML like this:
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:infoDetails>
...
</soapenv:infoDetails>
</soapenv:Body>
</Envelope>
As you can see the root element is without a prefix soapenv.
What I am doing wrong if I want the Envelope element to also has a prefix soapenv?
Thank you