【问题标题】:EnhancedAirBook3.2.0 not Deserialized the Retain Attibute增强的 AirBook 3.2.0 不反序列化保留属性
【发布时间】:2015-08-17 14:13:15
【问题描述】:

我们已将 EnhancedAirBook 升级到最新版本 3.2.0。
我们使用 Visual Studio 2013(更新 5)将 EnhancedAirBook 用作 Web 参考。
在代码中,我们设置了 EnhancedAirBook Request 对象。
在向请求添加 OTA_AirPriceRQ 时,我们设置 PriceRequestInformation Retain 属性="true"。
但是当我们将请求对象淡化为字符串并查看 XML 时,PriceRequestInformation 元素上不存在 Retain 属性(见下文)。

request.OTA_AirPriceRQ = new EnhancedAirBookRQOTA_AirPriceRQ
                {
                    PriceRequestInformation = new EnhancedAirBookRQOTA_AirPriceRQPriceRequestInformation
                    {
                        OptionalQualifiers =
                            new EnhancedAirBookRQOTA_AirPriceRQPriceRequestInformationOptionalQualifiers
                            {
                                PricingQualifiers =
                                    new EnhancedAirBookRQOTA_AirPriceRQPriceRequestInformationOptionalQualifiersPricingQualifiers
                                    {
                                        CurrencyCode = paramsService.Currency
                                    }
                            },
                        Retain = true
                    } 
                };

它的反序列化表示是:

<OTA_AirPriceRQ xmlns="http://services.sabre.com/sp/eab/v3_2">
 <PriceRequestInformation>
   <OptionalQualifiers>
      <PricingQualifiers CurrencyCode="USD">
       <PassengerType Code="ADT" Quantity="1" />
     </PricingQualifiers>
   </OptionalQualifiers>
 </PriceRequestInformation>

我们找到了解决方法。
备注/删除 EnhancedAirBook 的 Reference.cs 文件中的所有其他 PriceRequestInformation 属性,并仅保留 Retain 属性。 (见下文)
代码:

/// <remarks/>
    //[System.Xml.Serialization.XmlAttributeAttribute()]
    //public bool FutureTicket
    //{
    //    get
    //    {Re
    //        return this.futureTicketField;
    //    }
    //    set
    //    {
    //        this.futureTicketField = value;
    //    }
    //}

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

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public bool Retain {
        get {
            return this.retainField;
        }
        set {
            this.retainField = value;
        }
    }

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

它的反序列化表示是:

 <OTA_AirPriceRQ xmlns="http://services.sabre.com/sp/eab/v3_2">
<PriceRequestInformation Retain="true">
  <OptionalQua lifiers>
    <PricingQualifiers CurrencyCode="USD">
      <PassengerType Code="ADT" Quantity="1" />
    </PricingQualifiers>
  </OptionalQualifiers>
</PriceRequestInformation>

有没有其他方法可以在不修改 Reference.cs 文件的情况下设置属性?

【问题讨论】:

    标签: xml web-services serialization sabre


    【解决方案1】:

    设置 RetainSpecified = true 将解决问题。
    [AttributeName]指定的属性,用于设置可选的 xml 属性。

    【讨论】:

      猜你喜欢
      • 2017-03-10
      • 1970-01-01
      • 2018-12-11
      • 2021-05-26
      • 2016-01-14
      • 2019-06-30
      • 1970-01-01
      • 2013-10-09
      相关资源
      最近更新 更多