我使用以下代码来构造请求:
var dt = DateTime.UtcNow;
var tstamp = dt.ToString("s") + "Z";
var msgHeader = new com.Sabre.WebServiceConsumer.LLS.MessageHeader { ConversationId = convid };
var from = new com.Sabre.WebServiceConsumer.LLS.From();
var fromPartyId = new com.Sabre.WebServiceConsumer.LLS.PartyId();
var fromPartyIdArr = new com.Sabre.WebServiceConsumer.LLS.PartyId[1];
fromPartyId.Value = "WebServiceClient";
fromPartyIdArr[0] = fromPartyId;
from.PartyId = fromPartyIdArr;
msgHeader.From = from;
var to = new com.Sabre.WebServiceConsumer.LLS.To();
var toPartyId = new com.Sabre.WebServiceConsumer.LLS.PartyId();
var toPartyIdArr = new com.Sabre.WebServiceConsumer.LLS.PartyId[1];
toPartyId.Value = "https://sws3-crt.cert.sabre.com";
toPartyIdArr[0] = toPartyId;
to.PartyId = toPartyIdArr;
msgHeader.To = to;
msgHeader.CPAId = ipcc;
msgHeader.Action = "OTA_AirAvailLLSRQ";
var service = new com.Sabre.WebServiceConsumer.LLS.Service { Value = "AirAvail" };
msgHeader.Service = service;
//Create the request object req and the value for the IPCC in the payload of the request.
var flightSegments = new List<OTA_AirBookRQFlightSegment>();
foreach (var flightData in itinerary.FlightsData)
{
var currSeg = new OTA_AirBookRQFlightSegment()
{
Status = "QF",
FlightNumber = flightData.FlightNum,
NumberInParty = "1",
ResBookDesigCode = "Y",
OriginLocation =
new OTA_AirBookRQFlightSegmentOriginLocation
{
LocationCode
=
flightData
.Dep
},
DestinationLocation =
new OTA_AirBookRQFlightSegmentDestinationLocation
{
LocationCode
=
flightData
.Dest
},
MarketingAirline =
new OTA_AirBookRQFlightSegmentMarketingAirline
{
Code
=
flightData
.Carrier,
FlightNumber
=
flightData
.FlightNum
},
};
if (flightData.DepartureDate != null)
{
currSeg.DepartureDateTime = flightData.DepartureDate.Value.ToString("s");
}
if (flightData.ArrivalDate != null)
{
currSeg.ArrivalDateTime = flightData.ArrivalDate.Value.ToString("s");
}
flightSegments.Add(currSeg);
}
var req = new OTA_AirBookRQ {ReturnHostCommand = true, OriginDestinationInformation = flightSegments.ToArray()};
var msgData = new com.Sabre.WebServiceConsumer.LLS.MessageData
{
MessageId =
"mid:20001209-133003-2333@clientofsabre.com1",
Timestamp = tstamp
};
msgHeader.MessageData = msgData;
var security = new com.Sabre.WebServiceConsumer.LLS.Security1 { BinarySecurityToken = securitytoken };
var c = new OTA_AirBookPortTypeClient();
var resp = c.OTA_AirBookRQ(ref msgHeader, ref security, req);
if (resp.ApplicationResults.status == com.Sabre.WebServiceConsumer.LLS.CompletionCodes.Complete) return true;
我得到以下异常:
ERR.SWS.CLIENT.VALIDATION_FAILED
远程堆栈跟踪:服务器堆栈跟踪:在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) 在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 的 Object[] 输出,TimeSpan 超时)
在 [0] 处重新抛出异常:
我试图伪造书的行程是往返旅行,包含以下部分:DFW->LAS,出发:2016-02-07T00:00:00,到达:2016-02-07T00:00:00,承运人:NK, FlightNumber: 469 LAS->DFW, Departure: 2016-02-14T00:00:00, Arrival: 2016-02-14T00:00:00, Carrier: NK, FlightNumber: 470
所以我在 OriginDestinationInformation 中创建了带有 2 个 OTA_AirBookRQFlightSegment 的 OTA_AirBookRQ(一个用于入站 DFW->LAS,一个用于出站)
我什至尝试过使用日期/时间格式。例如给:2016-02-07T00:00 或:2016-02-07T 而不是 2016-02-07T00:00:00 但每次都得到相同的异常还尝试仅使用 DepartureDateTime (没有到达日期时间)并得到同样的结果。