Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:35:38+00:00 2026-05-23T22:35:38+00:00

I’m using a third part web service[WS] in my .Net app. My application is

  • 0

I’m using a third part web service[WS] in my .Net app.
My application is using the entity classes generated from this WS’s wsdl.
I fetch the data from db, fill it in entity objects and then generate an xml out of it using XmlSerializer class.

One of the methods of the WS requires this xml string as input.And the xml should have elements in the same order as expected by the WS.But whats happening is that some of the elements are getting upside down in my app and so WS is throwing an innermost exception saying on serialzation:.
_innerException {“Inconsistent sequencing: if used on one of the class’s members, the ‘Order’ property is required on all particle-like members, please explicitly set ‘Order’ using XmlElement, XmlAnyElement or XmlArray custom attribute on class member ‘instrument’.”} System.Exception {System.InvalidOperationException}

XmlSerializer serializer = new XmlSerializer(typeof(totemmessage));

So,my question here is, how do I programmatically control the order of these xml elements in my app before sending it to the WS?Note:I dont want to use xslt for this purpose.

Thanks for reading.

Here are my entity classes:

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(TypeName="totem-message")] 
    [System.Xml.Serialization.XmlRootAttribute("totem", Namespace="", IsNullable=false)] 
    public partial class totemmessage  { 

        private object itemField; 

        private ItemChoiceType1 itemElementNameField; 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute("error", typeof(errorinfo))] 
        [System.Xml.Serialization.XmlElementAttribute("parseReport", typeof(parseReportinfo))] 
        [System.Xml.Serialization.XmlElementAttribute("results", typeof(templateinfo))] 
        [System.Xml.Serialization.XmlElementAttribute("subareas", typeof(subareasinfo))] 
        [System.Xml.Serialization.XmlElementAttribute("template", typeof(templateinfo))] 
        [System.Xml.Serialization.XmlElementAttribute("upload", typeof(templateinfo))] 
        [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")] 
        [System.Xml.Serialization.XmlElement(Order = 0)]       
        public object Item { 
            get { 
                return this.itemField; 
            } 
            set { 
                this.itemField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 1)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()] 
        public ItemChoiceType1 ItemElementName { 
            get { 
                return this.itemElementNameField; 
            } 
            set { 
                this.itemElementNameField = value; 
            } 
        }        

    }

[System.Xml.Serialization.XmlIncludeAttribute(typeof(energyInstrument))] 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    public abstract partial class abstractEnergyInstrument { 

        private energyContractTime periodField; 

        private bool periodFieldSpecified; 

        private System.DateTime startDateField; 

        private bool startDateFieldSpecified; 

        private System.DateTime endDateField; 

        private bool endDateFieldSpecified; 

        private System.DateTime expiryDateField; 

        private bool expiryDateFieldSpecified; 

        private energyInstrumentClassifier typeField; 

        private bool typeFieldSpecified; 

        private string strikeField; 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 0)] 
        public energyContractTime period { 
            get { 
                return this.periodField; 
            } 
            set { 
                this.periodField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 1)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool periodSpecified { 
            get { 
                return this.periodFieldSpecified; 
            } 
            set { 
                this.periodFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute(DataType="date", Order =2)]        
        public System.DateTime startDate { 
            get { 
                return this.startDateField; 
            } 
            set { 
                this.startDateField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 3)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool startDateSpecified { 
            get { 
                return this.startDateFieldSpecified; 
            } 
            set { 
                this.startDateFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute(DataType="date", Order =4)]        
        public System.DateTime endDate { 
            get { 
                return this.endDateField; 
            } 
            set { 
                this.endDateField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 5)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool endDateSpecified { 
            get { 
                return this.endDateFieldSpecified; 
            } 
            set { 
                this.endDateFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute(DataType="date", Order =6)]        
        public System.DateTime expiryDate { 
            get { 
                return this.expiryDateField; 
            } 
            set { 
                this.expiryDateField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 7)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool expiryDateSpecified { 
            get { 
                return this.expiryDateFieldSpecified; 
            } 
            set { 
                this.expiryDateFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 8)] 
        public energyInstrumentClassifier type { 
            get { 
                return this.typeField; 
            } 
            set { 
                this.typeField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 9)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool typeSpecified { 
            get { 
                return this.typeFieldSpecified; 
            } 
            set { 
                this.typeFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 10)] 
        public string strike { 
            get { 
                return this.strikeField; 
            } 
            set { 
                this.strikeField = value; 
            } 
        } 
    }

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlRootAttribute("instrument", Namespace="", IsNullable=false)] 
    public partial class energyInstrument : abstractEnergyInstrument { 

        private decimal priceField; 

        private bool priceFieldSpecified; 

        private decimal forwardField; 

        private bool forwardFieldSpecified; 

        private decimal volField; 

        private bool volFieldSpecified; 

        private decimal consensusPriceField; 

        private bool consensusPriceFieldSpecified; 

        private decimal compositePriceField; 

        private bool compositePriceFieldSpecified; 

        private decimal reconstitutedForwardField; 

        private bool reconstitutedForwardFieldSpecified; 

        private decimal consensusVolField; 

        private bool consensusVolFieldSpecified; 

        private decimal compositeVolField; 

        private bool compositeVolFieldSpecified; 

        private string priceOutField; 

        private decimal priceRangeField; 

        private bool priceRangeFieldSpecified; 

        private decimal priceStddevField; 

        private bool priceStddevFieldSpecified; 

        private string volOutField; 

        private decimal volRangeField; 

        private bool volRangeFieldSpecified; 

        private decimal volStddevField; 

        private bool volStddevFieldSpecified; 

        private string contributorsField; 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 0)] 
        public decimal price { 
            get { 
                return this.priceField; 
            } 
            set { 
                this.priceField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 1)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool priceSpecified { 
            get { 
                return this.priceFieldSpecified; 
            } 
            set { 
                this.priceFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 2)] 
        public decimal forward { 
            get { 
                return this.forwardField; 
            } 
            set { 
                this.forwardField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 3)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool forwardSpecified { 
            get { 
                return this.forwardFieldSpecified; 
            } 
            set { 
                this.forwardFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 4)] 
        public decimal vol { 
            get { 
                return this.volField; 
            } 
            set { 
                this.volField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 5)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool volSpecified { 
            get { 
                return this.volFieldSpecified; 
            } 
            set { 
                this.volFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 6)] 
        public decimal consensusPrice { 
            get { 
                return this.consensusPriceField; 
            } 
            set { 
                this.consensusPriceField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 7)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool consensusPriceSpecified { 
            get { 
                return this.consensusPriceFieldSpecified; 
            } 
            set { 
                this.consensusPriceFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 8)] 
        public decimal compositePrice { 
            get { 
                return this.compositePriceField; 
            } 
            set { 
                this.compositePriceField = value; 
            } 
        } 

        /// <remarks/>        
        [System.Xml.Serialization.XmlElement(Order = 9)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool compositePriceSpecified { 
            get { 
                return this.compositePriceFieldSpecified; 
            } 
            set { 
                this.compositePriceFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 10)] 
        public decimal reconstitutedForward { 
            get { 
                return this.reconstitutedForwardField; 
            } 
            set { 
                this.reconstitutedForwardField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 11)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool reconstitutedForwardSpecified { 
            get { 
                return this.reconstitutedForwardFieldSpecified; 
            } 
            set { 
                this.reconstitutedForwardFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 12)] 
        public decimal consensusVol { 
            get { 
                return this.consensusVolField; 
            } 
            set { 
                this.consensusVolField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 13)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool consensusVolSpecified { 
            get { 
                return this.consensusVolFieldSpecified; 
            } 
            set { 
                this.consensusVolFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 14)] 
        public decimal compositeVol { 
            get { 
                return this.compositeVolField; 
            } 
            set { 
                this.compositeVolField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 15)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool compositeVolSpecified { 
            get { 
                return this.compositeVolFieldSpecified; 
            } 
            set { 
                this.compositeVolFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 16)] 
        public string priceOut { 
            get { 
                return this.priceOutField; 
            } 
            set { 
                this.priceOutField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 17)] 
        public decimal priceRange { 
            get { 
                return this.priceRangeField; 
            } 
            set { 
                this.priceRangeField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 18)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool priceRangeSpecified { 
            get { 
                return this.priceRangeFieldSpecified; 
            } 
            set { 
                this.priceRangeFieldSpecified = value; 
            } 
        } 

        /// <remarks/>

        [System.Xml.Serialization.XmlElement(Order = 19)] 
        public decimal priceStddev 
        { 
            get { 
                return this.priceStddevField; 
            } 
            set { 
                this.priceStddevField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 20)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool priceStddevSpecified { 
            get { 
                return this.priceStddevFieldSpecified; 
            } 
            set { 
                this.priceStddevFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 21)] 
        public string volOut { 
            get { 
                return this.volOutField; 
            } 
            set { 
                this.volOutField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 22)] 
        public decimal volRange { 
            get { 
                return this.volRangeField; 
            } 
            set { 
                this.volRangeField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 23)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool volRangeSpecified { 
            get { 
                return this.volRangeFieldSpecified; 
            } 
            set { 
                this.volRangeFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 24)] 
        public decimal volStddev { 
            get { 
                return this.volStddevField; 
            } 
            set { 
                this.volStddevField = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElement(Order = 25)] 
        [System.Xml.Serialization.XmlIgnoreAttribute()]        
        public bool volStddevSpecified { 
            get { 
                return this.volStddevFieldSpecified; 
            } 
            set { 
                this.volStddevFieldSpecified = value; 
            } 
        } 

        /// <remarks/> 
        [System.Xml.Serialization.XmlElementAttribute(DataType="integer", Order =26)]        
        public string contributors { 
            get { 
                return this.contributorsField; 
            } 
            set { 
                this.contributorsField = value; 
            } 
        } 
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:35:40+00:00Added an answer on May 23, 2026 at 10:35 pm

    I used XmlElement[Order =n] on top of each of the properties in the entity classes. So, after playing around with the ordering, I could made this serialization work.Inheritance and partial classes made this fix all the more difficult!Thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.