ali*_*ken 2 c# xml asp.net soap-client travelport-api
我现在用的是Travelport的通用API在试用模式现在。我的目标是开发一个 Web 门户来处理客户的 B2B 需求。一切都很好,直到我来到最后一步,即创建预订(预订)。我尝试按照下面附加的示例 Soap 请求 XML 使用所有必需的参数和数据填充请求对象:示例 XML 请求
以下是我编写的请求代码,其中包含示例 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);
Run Code Online (Sandbox Code Playgroud)
但是当我发送请求时,我在上面代码中提到的最后一行收到了 SoapException。例外是:Ticketing application failed: 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"
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1204 次 |
| 最近记录: |