Skip to main content
 首页 » 编程设计

c#之检查 Travelport Universal API AirCreateReservationReq 中的格式错误响应

2024年08月12日35shihaiming

我现在正在试用模式下使用Travelport Universal API。我的目标是开发一个 Web 门户来处理客户的 B2B 需求。一切都很好,直到我来到倒数第二个步骤,即 Creating reservation(预订)。我已尝试按照下面附带的示例 Soap 请求 XML 使用所有必需的参数和数据填充请求对象:Sample XML Request

以下是我编写的请求代码,其中包含示例 xml 请求中描述的详细信息。

var biPoint3 = new BillingPointOfSaleInfo { OriginApplication =      Crediantels.oritionApplication }; 
 
var delevieryInfo = new DeliveryInfo 
        { 
            Email = new Email { EmailID = "test@travelport.com", Type = "Home" }, 
            PhoneNumber = new PhoneNumber 
            { 
                CountryCode = "069", 
                AreaCode = "49", 
                Number = "261111111", 
                Type = PhoneNumberType.Mobile, 
                Location = "FRA" 
            }, 
            ShippingAddress = new DeliveryInfoShippingAddress 
            { 
                City = "Como", 
                Country = "IT", 
                PostalCode = "22100", 
                Street = new[] { "Some Street" } 
            }, 
        }; 
 
        var travelerDetails = new BookingTraveler 
        { 
            Key = "0", 
            DOB = new DateTime(1976, 11, 18), 
            Gender = "M", 
            TravelerType = "ADT", 
            BookingTravelerName = new BookingTravelerName 
            { 
                First = "Frederick", 
                Last = "Heinrich", 
                Prefix = "Herr" 
            }, 
            Address = new[] 
            { 
                new typeStructuredAddress 
                { 
                    AddressName = "Smiths", 
                    City = "Frankfurt", 
                    Country = "DE", 
                    PostalCode = "60311", 
                    Street = new[] {"Rossmarkt 6"}, 
                    State = new State {Value = "Hesse"} 
                } 
            }, 
            DeliveryInfo = new[] 
            { 
                new DeliveryInfo 
                { 
                    Email = new Email {EmailID = "test@travelport.com", Type = "Home"}, 
                    PhoneNumber = new PhoneNumber 
                    { 
                        CountryCode = "069", 
                        AreaCode = "49", 
                        Number = "261111111", 
                        Type = PhoneNumberType.Mobile, 
                        Location = "FRA" 
                    }, 
                    ShippingAddress = new DeliveryInfoShippingAddress 
                    { 
                        City = "Frankfurt", 
                        Country = "DE", 
                        PostalCode = "60311", 
                        Street = new[] {"Rossmarkt 6"} 
                    } 
                } 
            }, 
            Email = new[] { new Email { Type = "Home", EmailID = "test@travelport.com" } }, 
            PhoneNumber = new[] 
            { 
                new PhoneNumber 
                { 
                    CountryCode = "069", 
                    AreaCode = "49", 
                    Number = "261111111", 
                    Type = PhoneNumberType.Mobile, 
                    Location = "FRA" 
                } 
            } 
        }; 
 
        var reservationRequest = new AirCreateReservationReq 
        { 
            BillingPointOfSaleInfo = biPoint3, 
            TargetBranch = Crediantels.targetBranch, 
            AirPricingSolution = airPriceResponse.AirPriceResult[0].AirPricingSolution[0], 
            DeliveryInfo = delevieryInfo, 
            BookingTraveler = new[] { travelerDetails }, 
            FormOfPayment = new[] 
            { 
                new FormOfPayment 
                { 
                    Type = "Cash", 
                    Key = "jwt2mcK1Qp27I2xfpcCtAw==" 
                } 
            }, 
            ActionStatus = new[] 
            { 
                new ActionStatus 
                { 
                    Type = ActionStatusType.TTL, 
                    TicketDate = "2014-12-07T00:00:00", 
                    ProviderCode = "1G", 
                    QueueCategory = "01" 
                } 
            }, 
            AuthorizedBy = "myself", 
            RetainReservation = typeRetainReservation.Both, 
            TraceId = "1234" 
        }; 
 
        if (reservationRequest.AirPricingSolution.AirSegmentRef != null) 
        { 
            var airSegmentRef = reservationRequest.AirPricingSolution.AirSegmentRef[0].Key; 
            reservationRequest.AirPricingSolution.AirSegment = new[] { GetAirSegmentByKey(airPriceResponse, airSegmentRef) }; 
        } 
        reservationRequest.AirPricingSolution.AirSegmentRef = null; 
        reservationRequest.AirPricingSolution.AirPricingInfo[0].PassengerType[0].BookingTravelerRef = "0"; 
 
        var reservationBinding = new AirCreateReservationBinding 
        { 
            Url = Crediantels.url, 
            Credentials = new NetworkCredential(Crediantels.userName, Crediantels.password) 
        }; 
        //SoapException on the following line 
        var airReservationResponse = reservationBinding.service(reservationRequest);  

但是当我发送请求时,我在上面代码中提到的最后一行收到了 SoapException。异常是:票务申请失败:CHECK FORMAT。

通常,根据 Web 服务的期望,响应总是包含有关请求中缺少或不存在的内容的线索。

我已尝试在请求中添加所有详细信息,即使我不需要其中一些,只是为了匹配示例请求,但此异常仍然没有消失。

如果我故意跳过文档中要求提到的某些内容,我会得到一个可理解的响应,其中提到了缺失的项目或细节,但不是在原始情况下。

如果有任何想法可以引导我走向正确的方向,我将不胜感激。

请您参考如下方法:

通过一些命中和试验解决了这个问题。在这里发布作为答案,以帮助其他人寻找相同的答案。

由于 ActionStatusType.TTL 出现错误。它需要设置为 ActionStatusType.TAW。 TAW 代表 TicketAtWill。

通过更改,我的错误已更改为 *0 AVAIL/WL Closed*。但这是因为输入条件没有可供预订的航类。将标准更改为更长时间的出发和返回日期,我得到了包含预订详细信息的有效回复。

ActionStatus = new[] 
{ 
    new ActionStatus 
    { 
        Type = ActionStatusType.TAW, *** 
        TicketDate = "2014-12-07T00:00:00", 
        ProviderCode = "1G", 
        QueueCategory = "01" 
    } 
 },