Guideline: @XmlElementRefs maps to a xs:choice. This binds to a property with name item in the C# class. If there is another field/property named item in the Java class, there will be a name clash that .NET will resolve by generating name. To avoid the name clash, either change the name or use customization, for example @XmlElement(name="foo").
Example: Mapping a field or property using @XmlElementRefs
//-- Java code fragment
public class PurchaseOrder {
@XmlElementRefs({
@XmlElementRef(name="plane", type=PlaneType.class),
@XmlElementRef(name="auto", type=AutoType.class)})
public TransportType shipBy;
}
@XmlRootElement(name="plane")
public class PlaneType extends TransportType {}
@XmlRootElement(name="auto")
public class AutoType extends TransportType { }
@XmlRootElement
public class TransportType { ... }
//-- Schema fragment
<!-- XML schema generated by wsgen -->
<xs:complexType name="purchaseOrder">
<xs:choice>
<xs:element ref="plane"/>
<xs:element ref="auto"/>
</xs:choice>
</xs:complexType>
<!-- XML global elements -->
<xs:element name="plane" type="autoType" />
<xs:element name="auto" type="planeType" />
<xs:complexType name="autoType">
<!-- content omitted - details not relevant to example -->
</xs:complexType>
</xs:complexType name="planeType">
<!-- content omitted - details not relevant to example -->
</xs:complexType>
// .NET auto generated code from schema
public partial class purchaseOrder {
private transportType itemField;
[System.Xml.Serialization.XmlElementAttribute("auto", typeof(autoType), Order=4)]
[System.Xml.Serialization.XmlElementAttribute("plane", typeof(planeType), Order=4)]
public transportType Item
{
get { return this.itemField; }
set { this.itemField = value; }
}
public partial class planeType { ... } ;
public partial class autoType { ... } ;