0

Using VS 2013.
We are consuming some wsdl by Web Reference and getting all the classes of the ws.
We set value to the ws hierarchy attribute but the attribute is not serialized.
I saw here that one of the couses of attribute not getting serialized is:
"it has a public bool FooSpecified {get;set;} property or field that returned false."
So if we set the hierarchy attribute it's not represented in the XML:

familyInformation = new amadeus.Fare_SellByFareSearchFareFamiliesFamilyInformation
                   {
                      fareFamilyname = "XXXX",
                      hierarchy = 2
                   }



public decimal hierarchy {
        get {
            return this.hierarchyField;
        }
        set {
            this.hierarchyField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool hierarchySpecified {
        get {
            return this.hierarchyFieldSpecified;
        }
        set {
            this.hierarchyFieldSpecified = value;
        }
    }

<familyInformation>
  <fareFamilyname>XXXX</fareFamilyname>
</familyInformation>

Please help how to get the hierarchy attribute serialized

Community
  • 1
  • 1
N.D.B
  • 443
  • 7
  • 25

1 Answers1

1

You need to set both hierarchy and hierarchySpecified to true. hierarchy is declared as an optional attribute in the schema, and so hierarchySpecified was introduced to let the serializer know whether you want to have it in your XML or not (with true or false value).

ideafixxxer
  • 474
  • 3
  • 13