As PIEBALDconsult mentions, there is at least one error in your XML with the closing tag:
<envelope:envelope xmlns:envelope="http://xxx.com/data-hub/envelope">
<envelope:header>
<additionalInfo>
<Rebates/>
<Expenses>930879969</Expenses>
<Months>20</Months>
</additionalInfo>
</envelope:header>
</envelope:envelope>
Also, you are using mixed namespaces. There are two solutions:
1. add an additional namespace definition to the opening element:
<envelope:envelope xmlns:envelope="http://xxx.com/data-hub/envelope"
xmlns="http://xxx.com/data-hub/envelope">
<envelope:header>
<additionalInfo>
<Rebates/>
<Expenses>930879969</Expenses>
<Months>20</Months>
</additionalInfo>
</envelope:header>
</envelope:envelope>
2. All elements have the same namespace:
<envelope:envelope xmlns:envelope="http://xxx.com/data-hub/envelope">
<envelope:header>
<envelope:additionalInfo>
<envelope:Rebates/>
<envelope:Expenses>930879969</envelope:Expenses>
<envelope:Months>20</envelope:Months>
</envelope:additionalInfo>
</envelope:header>
</envelope:envelope>
Lastly, the
Envelope
class should be:
[XmlRoot(ElementName = "envelope", Namespace = "http://xxx.com/data-hub/envelope")]
public class Envelope
{
[XmlElement(ElementName = "header")]
public Header Header { get; set; }
}
And here are the other classes, used for testing, for consistancy:
public class Header
{
[XmlElement(ElementName = "additionalInfo")]
public AdditionalInfo AdditionalInfo { get; set; }
}
public class AdditionalInfo
{
[XmlElement(ElementName = "Rebates")]
public string Rebates { get; set; }
[XmlElement(ElementName = "Expenses")]
public string Expenses { get; set; }
[XmlElement(ElementName = "Months")]
public string Months { get; set; }
}