I am deserializing an XML file that comes from the web service of one of our clients.
The problem is that after creating the class with xsd.exe, I deserialize the file and get the usual "There is an error (2, 2) in the XML document." visual studio bug. This, I suppose, is line 2, which points to namespace declarations:
Top XML file:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"> <soapenv:Body><MXWorkorderOutResp language="EN" xmlns="http://www.mro.com/mx/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header event="0" operation="Response" rsCount="8" rsStart="0" rsTotal="8"> <SenderID build="127" dbbuild="V600-467" majorversion="6" minorversion="1" type="MAXIMO">MX</SenderID> <CreationDateTime>2009-05-11T09:48:51+01:00</CreationDateTime> <RecipientID>SUPPLIER</RecipientID> <MessageID>12420317323327108</MessageID> </Header> <Content> <MXWORKORDER> <WORKORDER>
Top Of Class:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.mro.com/mx/integration")] [System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.mro.com/mx/integration", IsNullable=false)] public partial class MXWorkorderOutResp { private MXWorkorderOutRespHeader[] headerField; private MXWorkorderOutRespContentMXWORKORDERWORKORDER[][][] contentField; private string languageField; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute("Header")] public MXWorkorderOutRespHeader[] Header { get { return this.headerField; } set { this.headerField = value; } } /// <remarks/> [System.Xml.Serialization.XmlArrayItemAttribute("MXWORKORDER", typeof(MXWorkorderOutRespContentMXWORKORDERWORKORDER[]), IsNullable=false)] [System.Xml.Serialization.XmlArrayItemAttribute("WORKORDER", typeof(MXWorkorderOutRespContentMXWORKORDERWORKORDER), IsNullable=false, NestingLevel=1)] public MXWorkorderOutRespContentMXWORKORDERWORKORDER[][][] Content {
I assume there is an error with:
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.mro.com/mx/integration")] [System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.mro.com/mx/integration", IsNullable=false)]
part of XML, but I donβt know how to change it - or what VS wants.
any help from all the rated guys is anyway, I'm still pretty new to all of this, and my boss is breathing to me all the time to get this to work :(
EDIT: There is an internal exception yes! Sorry guys!
{"<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'> was not expected."}
So how do I add this namespace declaration to a class?