我使用以下代码构造请求:
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
远程堆栈跟踪:服务器堆栈跟踪:at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc&amp; rpc)at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway,ProxyOperationRuntime操作,Object [] ins, 对象[]出局,TimeSpan超时)at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime operation)at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天 消息)
在[0]处重新抛出异常:
行程我正在尝试假书是以往的往返行程 细分:DFW-&gt; LAS,出发时间:2016-02-07T00:00:00,抵达: 2016-02-07T00:00:00,承运人:NK,FlightNumber:469 LAS-&gt; DFW, 出发时间:2016-02-14T00:00:00,抵达时间:2016-02-14T00:00:00,承运人: NK,FlightNumber:470
所以我创建了OTA_AirBookRQ,其中包含2个OTA_AirBookRQFlightSegment OriginDestinationInformation(一个用于入站DFW-> LAS,一个用于 出站)
我甚至试过玩日期/时间格式。例如给: 2016-02-07T00:00或:2016-02-07T而不是2016-02-07T00:00:00但是 每次都得到相同的例外也尝试使用 DepartureDateTime(没有到达日期时间)并得到相同的结果。
答案 0 :(得分:0)
您正在调用OTA_AirBookLLSRQ,但发送不同的Action msgHeader.Action =&#34; OTA_AirAvailLLSRQ&#34;;
如果请求的其余部分正确,只需更改为: msgHeader.Action =&#34; OTA_AirBookLLSRQ&#34;;