我在 C# 中使用 Sabre SOAP Api。我成功获得了会话创建的响应,我将 wsdl 服务参考http://webservices.sabre.com/wsdl/tpfc/OTA_AirAvailLLS2.3.0RQ.wsdl添加到我的测试项目中,并将所需的值传递给请求中的参数,如文档https://developer.sabre.com/docs/read/soap_apis/air/search/Air_Availability。
这是我使用 SOAP API 的代码
public OTA_AirAvailRS Method(string securitytoken, string convid, string ipcc)
{
try
{
DateTime dt = DateTime.UtcNow;
string tstamp = dt.ToString("s") + "Z";
//Create the message header. Provide the value for the conversation ID, the action code of the Web
//service being called, and the value for wsse:BinarySecurityToken that was returned with
//the SessionCreateRS message.
//This sample calls the OTA_AirAvailLLSRQ Service, and the action code that corresponds to
//this service is OTA_AirAvailLLSRQ.
MessageHeader msgHeader = new MessageHeader();
msgHeader.ConversationId = convid; // Put ConversationId in req header
From from = new From();
PartyId fromPartyId = new PartyId();
PartyId[] fromPartyIdArr = new PartyId[1];
fromPartyId.Value = "WebServiceClient";
fromPartyIdArr[0] = fromPartyId;
from.PartyId = fromPartyIdArr;
msgHeader.From = from;
To to = new To();
PartyId toPartyId = new PartyId();
PartyId[] toPartyIdArr = new PartyId[1];
toPartyId.Value = "WebServiceSupplier";
toPartyIdArr[0] = toPartyId;
to.PartyId = toPartyIdArr;
msgHeader.To = to;
msgHeader.CPAId = ipcc;
msgHeader.Action = "OTA_AirAvailLLSRQ";
Service service = new Service();
service.Value = "AirAvail";
msgHeader.Service = service;
MessageData msgData = new MessageData();
msgData.MessageId = "mid:20001209-133003-2333@clientofsabre.com1";
msgData.Timestamp = tstamp;
msgHeader.MessageData = msgData;
Security1 security = new Security1();
security.BinarySecurityToken = securitytoken; // Put BinarySecurityToken in req header
//Create the request object req and the value for the IPCC in the payload of the request.
OTA_AirAvailRQOriginDestinationInformationFlightSegment seg = new OTA_AirAvailRQOriginDestinationInformationFlightSegment()
{
ArrivalDateTime = "12-21T19:00",
DepartureDateTime = "12-21T18:00",
DestinationLocation = new OTA_AirAvailRQOriginDestinationInformationFlightSegmentDestinationLocation() { LocationCode = "DFW" },
OriginLocation = new OTA_AirAvailRQOriginDestinationInformationFlightSegmentOriginLocation() { LocationCode = "HNL" }
};
OTA_AirAvailRQ req = new OTA_AirAvailRQ();
req.OriginDestinationInformation = new OTA_AirAvailRQOriginDestinationInformation() { FlightSegment = seg };
// req.TimeStamp = tstamp;
// req.OptionalQualifiers.FlightQualifiers.
req.Version="2.3.0";
OTA_AirAvailPortTypeClient c = new OTA_AirAvailPortTypeClient();
OTA_AirAvailRS resp = c.OTA_AirAvailRQ(ref msgHeader, ref security, req);
return resp;
}
catch (Exception e)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine("Exception Stack Trace : " + e.StackTrace);
}
return new OTA_AirAvailRS();
}
它引发异常消息:ERR.SWS.CLIENT.VALIDATION_FAILED
堆:
服务器堆栈跟踪:
在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc& rpc)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)
在 [0] 处重新引发异常:在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 ConsoleApplication1.ServiceAirAvailLLSReference1 处的 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)。 OTA_AirAvailPortType.OTA_AirAvailRQ(OTA_AirAvailRQRequest request) at ConsoleApplication1.ServiceAirAvailLLSReference1.OTA_AirAvailPortTypeClient.ConsoleApplication1.ServiceAirAvailLLSReference1.OTA_AirAvailPortType.OTA_AirAvailRQ(OTA_AirAvailRQRequest request) in e:\ConsoleApplication1\ConsoleApplication1\Service References\ServiceAirAvailLLSReference1\Reference.cs:line 7012 at ConsoleApplication1.ServiceAirAvailLLSReference1.OTA_AirAvailPortTypeClient .OTA_AirAvailRQ(MessageHeader& MessageHeader, Security1& Security,e:\ConsoleApplication1\ConsoleApplication1\Service References\ServiceAirAvailLLSReference1\Reference.cs 中的 OTA_AirAvailRQ OTA_AirAvailRQ1):ConsoleApplication1.SearchAirAvail.Method(String securitytoken, String convid, String ipcc) 在 e:\ConsoleApplication1\ConsoleApplication1\SearchAirAvail.cs 中的第 7020 行:第 115 行
请帮我