我们已将 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 文件的情况下设置属性?