Access int value of enumeration in a message

Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Access int value of enumeration in a message

Viewing 1 reply thread
  • Author
    Posts
    • #21159

      I am referencing a WCF service from my orchestration and one of the generated XSD files the enum is defined as:

      <xs:element name=”OLI_LU_IDREFTYPE” nillable=”true” type=”tns:OLI_LU_IDREFTYPE” />
        <xs:simpleType name=”OLI_LU_PARTY”>
          <xs:restriction base=”xs:string”>
            <xs:enumeration value=”Person”>
              <xs:annotation>
                <xs:appinfo>
                  <EnumerationValue xmlns=”http://schemas.microsoft.com/2003/10/Serialization/”>1</EnumerationValue&gt;
                </xs:appinfo>
              </xs:annotation>
            </xs:enumeration>

      I then call the service and if I send the retrieved message out I get this in the message:

      <ns2:PartyTypeCode>Person</ns2:PartyTypeCode>

      Where the Person value is the value in the enumeration, but it’s the string value. I’d like to able to map both the string value as well as the integer value of the enumeration. Any ideas how I can cast it to the integer value (i.e. in C# I would do this

      int personId = (int)p.PartyTypeCode;

      Thanks.

    • #21165

      Xml schema is not able to describe an enumeration in terms of name and value like C#. It only has the string value.

      The EnumerationValue in the schema above is only an annotation (information only) it is generated and consumed by Microsoft specific serialization software.

      If you use the number 1 in your Xml it will be invalid according to the schema, which only allows the value “Person”. If you wish to use the values 1 and “Person” you will need to change the element definition and not use an enumeration. You will also need software to create and consume this Xml that is aware of the special nature of the data

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.