Xml deserialization with different namespace

s20

New Member
I'm trying to feed the xml a java web service spits out through xml deserialization, but seems the xml files I have are missing the namespaces. Here's the C# class generated from WSDL:\[code\][XmlTypeAttribute(Namespace="http://mynamespace.com")]public class Customer { [XmlElementAttribute(IsNullable=true)] public string customerNo { get; set; } [XmlElementAttribute(IsNullable=true)] public string customerType { get; set; }}\[/code\]See the namespace definition? The actual XML files miss the namespace declaration and look like this:\[code\]<?xml version="1.0"?><Customer> <customerNumber>1234</customerNumber> <customerType /></CreditCard>\[/code\]Xml deserializer deserializes the root object but all the properties are null. I managed to get it working by either removing the XmlTypeAttribute or adjusting the xml file by adding namespaces:\[code\]<xml version="1.0"?><Customer> <customerNumber xmlns="http://mynamespace.com">1234</creditCardNo> <customerType xsi:nil="true" xmlns="http://mynamespace.com" /></Customer>\[/code\]The problem is that the actual xml files are large and I don't want to do that manually and don't want to remove the attribute either. What's the easiest way to make it work? Regenerating the whole document with proper xmlns attributes and deserialize using that instead?
 
Back
Top