Josh
Josh

Reputation: 8477

VB.NET Case Insensitive Web Reference enumeration Issue

I created a Web Reference (also tried Service Reference) to a WSDL that had the following node inside an xsd:

  <xs:element name="filter">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="condition" />
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="filter" />
      </xs:choice>
      <xs:attribute default="and" name="type">
        <xs:simpleType>
          <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="and" />
            <xs:enumeration value="or" />
            <xs:enumeration value="AND" />
            <xs:enumeration value="OR" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
      <xs:attribute default="false" name="not" type="xs:boolean" />
    </xs:complexType>
  </xs:element>

When the client proxy class is created it produces this:

'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225"),  _
 System.SerializableAttribute(),  _
 System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn://wsc.acme.com/dm/2010/02/02")>  _
Public Enum filterType

    '''<remarks/>
    [and]

    '''<remarks/>
    [or]

    '''<remarks/>
    [AND]

    '''<remarks/>
    [OR]
End Enum

This wouldn't build in a VB project because VB.NET is case insensitive. I tried deleting one set of and/or, but when the XML is created, it simply ignores the selected value. I also tried appending an X at the end of one the sets which also failed.

Is there a way to make this work? I also tried updating the XSD so it just had two values without success. The interesting thing to note is that default is set to "and" and while debugging it will set it to and, it doesn't actually produce the node attribute of it just generates .

Upvotes: 1

Views: 597

Answers (1)

Mike Calvert
Mike Calvert

Reputation: 131

You simply cannot have two enums with the same name. You can try setting the AllowMultiple attribute but the problem you are experiencing will still happen. My suggestion would be to remove the duplicate values in the original XSD and rebuild.

Upvotes: 0

Related Questions