VB.NET案例不敏感的Web引用枚举问题

时间:2012-04-15 21:37:47

标签: vb.net web-services service-reference web-reference

我为一个在xsd中包含以下节点的WSDL创建了一个Web引用(也是尝试过的服务引用):

  <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>

创建客户端代理类时,它会生成:

'''<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

这不会构建在VB项目中,因为VB.NET不区分大小写。我尝试删除一组和/或,但是当创建XML时,它只是忽略所选的值。我也尝试在一个也失败的集合的末尾添加一个X.

有没有办法让这项工作?我也尝试更新XSD,因此只有两个值没有成功。有趣的是要将默认设置为“和”,并且在调试时将其设置为,并且它实际上不会生成它刚刚生成的节点属性。

1 个答案:

答案 0 :(得分:0)

你根本不能有两个同名的枚举。您可以尝试设置AllowMultiple属性,但仍会遇到您遇到的问题。我的建议是删除原始XSD中的重复值并重建。