locked
XML Serilization Error - xmlns was not expected - xmlns RRS feed

  • Question

  • I have a object that serializes just fine and looks like this 

    - <Plan xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Digitas.GSS.Services">
      <dentalPremiumField i:nil="true" /> 
      <medicalPremiumField i:nil="true" /> 
      <planIdField>1212</planIdField> 
      <planTitleField>This is the plan title</planTitleField> 
      <sbcDocumentField i:nil="true" /> 
      <supplementalDocumentField i:nil="true" /> 
      <totalPremiumField>0</totalPremiumField> 
      <totalPremiumFieldSpecified>false</totalPremiumFieldSpecified> 
      </Plan>

    but when I try to Deserialize I get this error

    <Plan xmlns='http://schemas.datacontract.org/2004/07/Digitas.GSS.Services'> was not expected.

    What in the world could I be missing...here is my class

       [System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://schema.worldlife.com/2013/05/sRQ/shopping")]
        [XmlRoot(Namespace = "http://schema.worldlife.com/2013/05/sRQ/shopping")]
        public partial class Plan
        {
    
            private string planIdField;
    
            private string planTitleField;
    
            private Document sbcDocumentField;
    
            private Premium medicalPremiumField;
    
            private Premium dentalPremiumField;
    
            private decimal totalPremiumField;
    
            private bool totalPremiumFieldSpecified;
    
            private Document supplementalDocumentField;
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 0)]
            public string planId
            {
                get { return this.planIdField; }
                set { this.planIdField = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 1)]
            public string planTitle
            {
                get { return this.planTitleField; }
                set { this.planTitleField = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 2)]
            public Document sbcDocument
            {
                get { return this.sbcDocumentField; }
                set { this.sbcDocumentField = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 3)]
            public Premium medicalPremium
            {
                get { return this.medicalPremiumField; }
                set { this.medicalPremiumField = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 4)]
            public Premium dentalPremium
            {
                get { return this.dentalPremiumField; }
                set { this.dentalPremiumField = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 5)]
            public decimal totalPremium
            {
                get { return this.totalPremiumField; }
                set { this.totalPremiumField = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlIgnoreAttribute()]
            public bool totalPremiumSpecified
            {
                get { return this.totalPremiumFieldSpecified; }
                set { this.totalPremiumFieldSpecified = value; }
            }
    
            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute(Order = 6)]
            public Document supplementalDocument
            {
                get { return this.supplementalDocumentField; }
                set { this.supplementalDocumentField = value; }
            }
        }

    I think i am missing some attribute or something


    Give youself a round of applause!!

    Wednesday, December 5, 2012 10:08 PM

All replies

  • I think you must have got that schema from the wrong place. The two namespaces are very different. The XML says "http://schemas.datacontract.org/2004/07/Digitas.GSS.Services", but the code says http://schema.worldlife.com/2013/05/sRQ/shopping.

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Thursday, December 6, 2012 7:07 PM
    Moderator