none
Webová služba - choice element

    Dotaz

  • Zdravím,

    jak přiřadit hodnotu pro choice element - viz. příklad:

    ws_test.AType my_ws = new AType();

    my_ws.AData = new ADataType();
    my_ws.AData.Item ??


    namespace ws_test
    {
        [Serializable]
        [DebuggerStepThrough]
        [XmlType(AnonymousType = true, Namespace = "urn:cz:aaa:bbb:schemas:zzz:v1")]
        [GeneratedCode("System.Xml", "4.0.30319.1")]
        [DesignerCategory("code")]
        public class ATypeReq
        {
            public ATypeReq();

            public ADataType AData { get; set; }
        }

        [Serializable]
        [DesignerCategory("code")]
        [GeneratedCode("System.Xml", "4.0.30319.1")]
        [DebuggerStepThrough]
        [XmlType(Namespace = "urn:cz:aaa:bbb:schemas:xxx:v2")]
        public class ADataType
        {
            public ADataType();

            [XmlElement("AElement", typeof(ADataTypeAA))]
            [XmlElement("BElement", typeof(ADataTypeBB))]
            public AStavAbstractType Item { get; set; }
        }
    }

      <xs:complexType name="ADataType">
        <xs:annotation>
          <xs:documentation xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:lang="cs">               
                </xs:documentation>
        </xs:annotation>
        <xs:choice>
          <xs:element name="AElement">
            <xs:complexType>
              <xs:complexContent mixed="false">
                <xs:extension base="edi:AStavAbstractType">
                  <xs:sequence>
                    <xs:element minOccurs="0" name="AA" type="edi:AAStavType" />
                  </xs:sequence>
                </xs:extension>
              </xs:complexContent>
            </xs:complexType>
          </xs:element>
          <xs:element name="BElement">
            <xs:complexType>
              <xs:complexContent mixed="false">
                <xs:extension base="edi:AStavAbstractType">
                  <xs:sequence>
                    <xs:element name="BB" type="edi:BBStavType" />
                  </xs:sequence>
                </xs:extension>
              </xs:complexContent>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>

    Děkuji.

    19. října 2012 15:07