Consider a .NET client calling into a remote XML SOAP web service that's defined as a Web Reference. The client calls the service, and is attempting to deserialize the return XML into an object.
The web method is executing properly, and the XML returned from the service is well formed, confirmed in Fiddler. The web service is a known good working service, as we have another client (.NET 2.0) consuming it without issue.
When the .NET web service proxy classes attempt to deserialize the returned XML, this error is thrown:
System.InvalidOperationException: There is an error in XML document (1, 1999). ---> System.Xml.XmlException: 'EndElement' is an invalid XmlNodeType. Line 1, position 1999. at System.Xml.XmlReader.ReadStartElement()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader_PRPA_AR101202_Service.Read135_MCCI_MT000200LocatedEntity(Boolean isNullable, Boolean checkType)
The line/column (1,1999) of the XML response that it's complaining about is the /
in </device>
:
<sender>
<device>
..snip..
<location classCode="IDENT" realmCode="xyz" />
</device>
How can I resolve this issue with .NET deserialization?
Attempted solutions with no resolution / more information:
- moved from .NET 4 to 4.5, hoping to see any fixes in the newest
System.Xml
- de-identified response document being deserialized
- full stack trace