AIXM 4.5 C# Class Generation Works Only With Arrays

Feb 22, 2009 at 10:22 AM
Edited Feb 22, 2009 at 10:24 AM
Hello, first of all I would like to thank you for a great piece of software. However I have some problems with generating classes from AIXM 4.5 schema files when using everything else except arrays. Actually, the code generation itself pretty much OK, but the following xml data deserialization always throws the "Type of choice identifier 'ItemElementName' is inconsisitent with type of 'Item'. Please use array of <namespace>.ItemChoiceType." exception. The data is read properly only when collection type ARRAY is used for code generation. Maybe I am doing something wrong, so could you please test the following examples?

Thanx a lot in advance.
Feb 25, 2009 at 8:53 AM
I encounter the very same problem. As workaround I use arrays so far. But a solution would be appreciated.
Mar 12, 2009 at 9:34 PM
Same here with fpml schema:

System.InvalidOperationException: There was an error reflecting property 'Items'. ---> System.InvalidOperationException: Type of choice identifier 'ItemsElementName' is inconsistent with type of 'Items'. Please use array of System.Collections.Generic.List`1[[MyTest.Model.Fpml.ItemsChoiceType3, MyTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].

Jul 10, 2009 at 7:16 AM

Hi FOlks,

 

 

I love this software, thanks! You have saved my web methods to being type safe. I also have the problem above though:

 

I am doing this on the STAR BOD 5 schema:

Test method MMIT.GMDS.BOL.TESTS.MessageHandlerFileMetData.DeserializeStar threw exception:  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.ProcessSalesLeadType'. --->  System.InvalidOperationException: There was an error reflecting property 'ProcessSalesLeadDataArea'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.ProcessSalesLeadDataAreaType'. --->  System.InvalidOperationException: There was an error reflecting property 'SalesLead'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.SalesLeadType'. --->  System.InvalidOperationException: There was an error reflecting property 'SalesLeadHeader'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.SalesLeadHeaderType'. --->  System.InvalidOperationException: There was an error reflecting property 'CustomerProspect'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.CustomerProspectType'. --->  System.InvalidOperationException: There was an error reflecting property 'ProspectParty'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.PartyABIEType'. --->  System.InvalidOperationException: There was an error reflecting property 'Item'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.PersonType'. --->  System.InvalidOperationException: There was an error reflecting property 'ResidenceAddress'. --->  System.InvalidOperationException: There was an error reflecting type 'MMIT.GMDS.BOL.Star.AddressABIEType'. --->  System.InvalidOperationException: There was an error reflecting property 'Items'. --->  System.InvalidOperationException: Type of choice identifier 'ItemsElementName' is inconsistent with type of 'Items'. Please use array of System.Collections.Generic.List`1[[MMIT.GMDS.BOL.Star.ItemsChoiceType, MMIT.GMDS.BOL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]..

 

This is the portion that is not working:

 

 [System.Xml.Serialization.XmlElementAttribute("BuildingName", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("BuildingNumber", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("BuildingNumberSuffix", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("FloorIdentification", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("LineFive", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("LineFour", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("LineOne", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("LineThree", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("LineTwo", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("PostOfficeBox", typeof(TextType))]
        [System.Xml.Serialization.XmlElementAttribute("StreetName", typeof(TextType))]
        [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
        public List<TextType> Items
        {
            get
            {
                return this.itemsField;
            }
            set
            {
                this.itemsField = value;
            }
        }

        [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public List<ItemsChoiceType> ItemsElementName
        {
            get
            {
                return this.itemsElementNameField;
            }
            set
            {
                this.itemsElementNameField = value;
            }
        }

 

[System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "2.8.2.29599")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.starstandard.org/STAR/5", IncludeInSchema = false)]
    public enum ItemsChoiceType
    {

        /// <remarks/>
        BuildingName,

        /// <remarks/>
        BuildingNumber,

        /// <remarks/>
        BuildingNumberSuffix,

        /// <remarks/>
        FloorIdentification,

        /// <remarks/>
        LineFive,

        /// <remarks/>
        LineFour,

        /// <remarks/>
        LineOne,

        /// <remarks/>
        LineThree,

        /// <remarks/>
        LineTwo,

        /// <remarks/>
        PostOfficeBox,

        /// <remarks/>
        StreetName,
    }

 

 

 

 

Feb 2, 2010 at 9:03 PM

Any progress on this issue? Im fighting the same thing with the latest 3.3 beta.

The same xml will deserialize with the xsd generated version, but the xsd2code version (using generic lists) fails to deser.

If it helps, Im using the microsoft reporting services 2005 schema, available here: 

http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition/ReportDefinition.xsd

 

 

Feb 18, 2010 at 10:39 AM
Edited Feb 18, 2010 at 12:18 PM

 

I'm facing the same problem with some schemas from SDMX (www.sdmx.org).

Even when I change the collectionObjectType to "Array", a different error still occurs.

Is there any progress on this issue?

I saw now that this problem can be found in "Issue tracker" page, here:
http://xsd2code.codeplex.com/WorkItem/View.aspx?WorkItemId=9877

If this is important for you, please vote!
:) 

 

Sep 28, 2010 at 10:53 PM

I'm also facing this issue.

Oct 27, 2010 at 5:53 PM

Best integrated tool so far, but would love the "array only" issue to be solved. My vote you have :)

Using 3.5

Sep 9, 2011 at 3:01 PM

I can't get a workaround for this problem so dumping xsd2code

Oct 20, 2011 at 6:05 PM

Also seeing this problem in 3.4 during deserialization of an nmap xml output file. I used visual studio xml editor to generate the xsd from the dtd at http://nmap.org/svn/docs/nmap.dtd and then ran against that.

InvalidOperationException thrown by XmlSerializer with message...

Type of choice identifier 'ItemsElementName' is inconsistent with type of 'Items'. Please use array of System.Collections.Generic.List`1[[Nmap.ItemsChoiceType, Nmap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].

and stack trace

   at System.Xml.Serialization.XmlReflectionImporter.CheckChoiceIdentifierType(Type type, Boolean isArrayLike, String identifierName, String memberName)   at System.Xml.Serialization.XmlReflectionImporter.GetChoiceIdentifierType(XmlChoiceIdentifierAttribute choice, StructModel structModel, Boolean isArrayLike, String accessorName)   at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)   at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)

..from generated code...

        [System.Xml.Serialization.XmlChoiceIdentifierAttribute( "ItemsElementName" )]
        public List<object> Items
        {
            get
            {
                return this.itemsField;
            }
            set
            {
                this.itemsField = value;
            }
        }

        [System.Xml.Serialization.XmlIgnoreAttribute( )]
        public List<ItemsChoiceType> ItemsElementName
        {
            get
            {
                return this.itemsElementNameField;
            }
            set
            {
                this.itemsElementNameField = value;
            }
        }

Suggested workaround of using Array leads to further InvalidOperationException...

{"Type Nmap.ItemsChoiceType is missing enumeration value 'Items' for element 'Items' from namespace ''."}

Oct 3, 2012 at 9:31 PM
pokinhas wrote:

 

I'm facing the same problem with some schemas from SDMX (www.sdmx.org).

Even when I change the collectionObjectType to "Array", a different error still occurs.

Is there any progress on this issue?

I saw now that this problem can be found in "Issue tracker" page, here:
http://xsd2code.codeplex.com/WorkItem/View.aspx?WorkItemId=9877

If this is important for you, please vote!
:) 

 

Thanks to pokinhas (Feb 18 2010 at 5:39 AM). It works the solution provided by "daliboris" (wrote Dec 15 2011 at 4:43 AM) in that link. The link he/she give us help me. I change both Items and ItemsElementName collections to array in the attribute, property and constructor sections. That's was enough for me, tahnks. I hope this help to everybody.