public string AirAvailMethod(string convid, string ipcc, string securitytoken, string origin, string destination) { string response = string.Empty; 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 = "99999"; fromPartyIdArr[0] = fromPartyId; from.PartyId = fromPartyIdArr; msgHeader.From = from; To to = new To(); PartyId toPartyId = new PartyId(); PartyId[] toPartyIdArr = new PartyId[1]; toPartyId.Value = "123123"; 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:[email protected]"; msgData.Timestamp = tstamp; msgHeader.MessageData = msgData; Security security = new Security(); 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_AirAvailRQ req = new OTA_AirAvailRQ(); OTA_AirAvailRQPOS pos = new OTA_AirAvailRQPOS(); OTA_AirAvailRQPOSSource source = new OTA_AirAvailRQPOSSource(); source.PseudoCityCode = ipcc; pos.Source = source; req.POS = pos; req.Version = "2003A.TsabreXML1.1.1"; // Specify the service version //Set the request data. OTA_AirAvailRQOriginDestinationInformation origDestInf = new OTA_AirAvailRQOriginDestinationInformation(); OTA_AirAvailRQOriginDestinationInformationDepartureDateTime departTime = new OTA_AirAvailRQOriginDestinationInformationDepartureDateTime(); string dateRngStart = DateTime.Now.AddDays(45).ToString("s"); //45 days in future departTime.DateTime = dateRngStart; origDestInf.DepartureDateTime = departTime; OTA_AirAvailRQOriginDestinationInformationOriginLocation originLoc = new OTA_AirAvailRQOriginDestinationInformationOriginLocation(); originLoc.LocationCode = origin;//"LAX"; originLoc.CodeContext = "IATA"; origDestInf.OriginLocation = originLoc; OTA_AirAvailRQOriginDestinationInformationDestinationLocation destLoc = new OTA_AirAvailRQOriginDestinationInformationDestinationLocation(); destLoc.LocationCode = destination; //"NYC"; destLoc.CodeContext = "IATA"; origDestInf.DestinationLocation = destLoc; req.OriginDestinationInformation = origDestInf; OTA_AirAvailRQSpecificFlightInfo specFlt = new OTA_AirAvailRQSpecificFlightInfo(); OTA_AirAvailRQSpecificFlightInfoTPA_Extensions specFltTpa = new OTA_AirAvailRQSpecificFlightInfoTPA_Extensions(); OTA_AirAvailRQSpecificFlightInfoTPA_ExtensionsAdditionalAvail addlAvail = new OTA_AirAvailRQSpecificFlightInfoTPA_ExtensionsAdditionalAvail(); // NOTE: // To request additional availability (1*), set Ind=true. // To request additional class availability (1*C), set Ind=true and ClassInd=true. addlAvail.Ind = false; addlAvail.ClassInd = false; specFltTpa.AdditionalAvail = addlAvail; specFlt.TPA_Extensions = specFltTpa; req.SpecificFlightInfo = specFlt; OTA_AirAvailService serviceObj = new OTA_AirAvailService(); serviceObj.MessageHeaderValue = msgHeader; serviceObj.SecurityValue = security; //Call the service and assign the response object. OTA_AirAvailRS resp = serviceObj.OTA_AirAvailRQ(req); // Send the request. //Retrieve data from the resp object, such as flight number and airline code, and display //it on standard output. the client can retrieve other data from the response the same way. response = string.Concat(response, "*********************************************" + "\n"); response = string.Concat(response, "Response of OTA_AirAvail Service" + "\n"); if (resp.Errors != null && resp.Errors.Error != null) { response = string.Concat(response, "Error : " + resp.Errors.Error.ErrorInfo.Message + "\n"); } else { response = string.Concat(response, "Requested " + originLoc.LocationCode + " to " + destLoc.LocationCode + "\n"); int ondSize = resp.OriginDestinationOptions.Length; response = string.Concat(response, "Number of itineraries returned : " + ondSize + "\n"); for (int i1 = 0; i1 < ondSize; i1++) { int segSize = resp.OriginDestinationOptions[i1].FlightSegment.Length; for (int s1 = 0; s1 < segSize; s1++) { if (originLoc.LocationCode != resp.OriginDestinationOptions[i1].FlightSegment[s1].DepartureAirport.LocationCode) { response = string.Concat(response, "Departure Airport : " + resp.OriginDestinationOptions[i1].FlightSegment[s1].DepartureAirport.LocationCode + "\n"); } if (destLoc.LocationCode != resp.OriginDestinationOptions[i1].FlightSegment[s1].ArrivalAirport.LocationCode) { response = string.Concat(response, "Arrival Airport : " + resp.OriginDestinationOptions[i1].FlightSegment[s1].ArrivalAirport.LocationCode + "\n"); } response = string.Concat(response, "Marketing Carrier : " + resp.OriginDestinationOptions[i1].FlightSegment[s1].MarketingAirline.Code + "\n"); response = string.Concat(response, "Flight number : " + resp.OriginDestinationOptions[i1].FlightSegment[s1].FlightNumber + "\n"); response = string.Concat(response, "Departure : " + resp.OriginDestinationOptions[i1].FlightSegment[s1].DepartureDateTime + "\n"); response = string.Concat(response, "Arrival : " + resp.OriginDestinationOptions[i1].FlightSegment[s1].ArrivalDateTime + "\n"); response = string.Concat(response, "Timezone Diff : " + resp.OriginDestinationOptions[i1].TPA_Extensions.TimeZoneDifference.Code + "\n"); } } response = string.Concat(response, "Host command : " + resp.TPA_Extensions.HostCommand + "\n"); } response = string.Concat(response, "********************************************" + "\n"); //Console.Read(); } //Catch exceptions and parse the error and stack trace. catch (Exception e) { response = string.Concat(response, "Exception Message : " + e.Message + "\n"); response = string.Concat(response, "Exception Stack Trace : " + e.StackTrace + "\n"); //Console.Read(); } return(response); }
public OTA_AirAvailRS getBusquedaHora(VO_OTA_AirLowFareSearchLLSRQ vo_OTA_AirLowFareSearchLLSRQ) { /*METODO PRINCICPAL QUE RETORNA EL OBJETO DE RESULTADOS DE SABRE*/ clsParametros cParametros = new clsParametros(); StringBuilder consulta = new StringBuilder(); cParametros.TipoWs = Enum_ProveedorWebServices.Sabre; csVuelos cVuelos = new csVuelos(); try { if (vo_OTA_AirLowFareSearchLLSRQ.LsAerolineaPreferida.Count.Equals(0)) { vo_OTA_AirLowFareSearchLLSRQ.LsAerolineaPreferida = cVuelos.AerolineasPreferidas(); } } catch { } if (vo_OTA_AirLowFareSearchLLSRQ.LsAerolineaPreferida.Count.Equals(0)) { vo_OTA_AirLowFareSearchLLSRQ.LsExcluirAerolinea = cVuelos.ExcluirAerolineas(); } //bool PriorityTime = true; OTA_AirAvailRQ.OTA_AirAvailRQ oOTA_AirLowFareSearchRQ = new OTA_AirAvailRQ.OTA_AirAvailRQ(); OTA_AirAvailRS oOTA_AirLowFareSearchRS = new OTA_AirAvailRS(); objvo_Credentials = Ssoft.Utils.clsSesiones.getCredentials(); try { List <string> lsContadorOpciones = new List <string>(); OTA_AirAvail.MessageHeader Mensaje_ = clsSabreBase.OTA_AirAvail(); if (Mensaje_ != null) { OTA_AirAvail.Security Seguridad_ = new OTA_AirAvail.Security(); Seguridad_.BinarySecurityToken = Session_; #region [ POS ] OTA_AirAvailRQPOS oOTA_AirLowFareSearchRQPOS = new OTA_AirAvailRQPOS(); OTA_AirAvailRQPOSSource oOTA_AirLowFareSearchRQPOSSource = new OTA_AirAvailRQPOSSource(); oOTA_AirLowFareSearchRQPOSSource.PseudoCityCode = objvo_Credentials.Pcc;//ConfigurationManager.AppSettings["Sabre_Ipcc"]; oOTA_AirLowFareSearchRQPOS.Source = oOTA_AirLowFareSearchRQPOSSource; oOTA_AirLowFareSearchRQ.POS = oOTA_AirLowFareSearchRQPOS; #endregion #region [ VERSION ] oOTA_AirLowFareSearchRQ.Version = clsSabreBase.SABRE_VERSION_OTA_AIRAVAIL; #endregion #region [ ORIGINDESTINATIONINFORMATION ] List <VO_OriginDestinationInformation> lvo_Rutas = vo_OTA_AirLowFareSearchLLSRQ.Lvo_Rutas; if (lvo_Rutas == null) { throw new Exception("No se recibieron rutas a procesar"); } else { int iOriginDestinationInformation = vo_OTA_AirLowFareSearchLLSRQ.Ruta; VO_OriginDestinationInformation vo_OriginDestinationInformation = lvo_Rutas[iOriginDestinationInformation]; OTA_AirAvailRQOriginDestinationInformation oOTA_AirLowFareSearchRQOriginDestinationInformation = new OTA_AirAvailRQOriginDestinationInformation(); OTA_AirAvailRQOriginDestinationInformationDepartureDateTime DepartureDateTime = new OTA_AirAvailRQOriginDestinationInformationDepartureDateTime(); //oOTA_AirLowFareSearchRQOriginDestinationInformation.ExcludeCodeShare = false; DepartureDateTime.DateTime = vo_OriginDestinationInformation.SFechaSalida; oOTA_AirLowFareSearchRQOriginDestinationInformation.DepartureDateTime = DepartureDateTime; if (vo_OriginDestinationInformation.Vo_AeropuertoOrigen != null) { VO_Aeropuerto vo_Origen = vo_OriginDestinationInformation.Vo_AeropuertoOrigen; OTA_AirAvailRQOriginDestinationInformationOriginLocation oOriginLocation = new OTA_AirAvailRQOriginDestinationInformationOriginLocation(); oOriginLocation.CodeContext = vo_Origen.SContexto; oOriginLocation.LocationCode = vo_Origen.SCodigo; oOTA_AirLowFareSearchRQOriginDestinationInformation.OriginLocation = oOriginLocation; } VO_Aeropuerto vo_Destino = vo_OriginDestinationInformation.Vo_AeropuertoDestino; OTA_AirAvailRQOriginDestinationInformationDestinationLocation oDestinationLocation = new OTA_AirAvailRQOriginDestinationInformationDestinationLocation(); oDestinationLocation.LocationCode = vo_Destino.SCodigo; oDestinationLocation.CodeContext = vo_Destino.SContexto; oOTA_AirLowFareSearchRQOriginDestinationInformation.DestinationLocation = oDestinationLocation; #region [ TPA_EXTENSIONS ] //OTA_AirAvailRQOriginDestinationInformationTPA_Extensions oOriginDestinationInformationTPA_Extensions = // new OTA_AirAvailRQOriginDestinationInformationTPA_Extensions(); //OTA_AirAvailRQOriginDestinationInformationTPA_ExtensionsArrivalDateTime TPA_ExtensionsArrivalDateTime = // new OTA_AirAvailRQOriginDestinationInformationTPA_ExtensionsArrivalDateTime(); //OTA_AirAvailRQOriginDestinationInformationTPA_ExtensionsScan TPA_ExtensionsScan = // new OTA_AirAvailRQOriginDestinationInformationTPA_ExtensionsScan(); //TPA_ExtensionsArrivalDateTime.DateTime = vo_OriginDestinationInformation.SFechaSalida; //TPA_ExtensionsScan.Ind = true; //TPA_ExtensionsScan.IndSpecified = true; //oOriginDestinationInformationTPA_Extensions.ArrivalDateTime = TPA_ExtensionsArrivalDateTime; //oOriginDestinationInformationTPA_Extensions.Scan = TPA_ExtensionsScan; //oOTA_AirLowFareSearchRQOriginDestinationInformation.TPA_Extensions = // oOriginDestinationInformationTPA_Extensions; #endregion oOTA_AirLowFareSearchRQ.OriginDestinationInformation = oOTA_AirLowFareSearchRQOriginDestinationInformation; } #endregion #region [ TRAVELPREFERENCES ] OTA_AirAvailRQTravelPreferences oOTA_AirLowFareSearchRQTravelPreferences = new OTA_AirAvailRQTravelPreferences(); string sMaximasParadas = vo_OTA_AirLowFareSearchLLSRQ.SMaximasParadas; if (clsValidaciones.getValidarString(sMaximasParadas)) { if (sMaximasParadas.Equals("0")) { oOTA_AirLowFareSearchRQTravelPreferences.MaxStopsQuantity = sMaximasParadas; } } List <string> lsAerolineaPreferida = vo_OTA_AirLowFareSearchLLSRQ.LsAerolineaPreferida; if (lsAerolineaPreferida != null) { int iContadorAerolinea = 0; OTA_AirAvailRQTravelPreferencesVendorPref[] aOTA_AirLowFareSearchRQTravelPreferencesVendorPref = new OTA_AirAvailRQTravelPreferencesVendorPref[lsAerolineaPreferida.Count]; foreach (string sAerolineaPreferida in lsAerolineaPreferida) { OTA_AirAvailRQTravelPreferencesVendorPref oOTA_AirLowFareSearchRQTravelPreferencesVendorPref = new OTA_AirAvailRQTravelPreferencesVendorPref(); oOTA_AirLowFareSearchRQTravelPreferencesVendorPref.Code = sAerolineaPreferida.Trim(); aOTA_AirLowFareSearchRQTravelPreferencesVendorPref[iContadorAerolinea] = oOTA_AirLowFareSearchRQTravelPreferencesVendorPref; iContadorAerolinea++; } oOTA_AirLowFareSearchRQTravelPreferences.VendorPref = aOTA_AirLowFareSearchRQTravelPreferencesVendorPref; } List <string> lsClases = vo_OTA_AirLowFareSearchLLSRQ.LsClase; try { if (lsClases != null) { if (lsClases.Count > 0) { OTA_AirAvailRQTravelPreferencesCabinPref oCabinPref = new OTA_AirAvailRQTravelPreferencesCabinPref(); oCabinPref.Cabin = lsClases[0]; oOTA_AirLowFareSearchRQTravelPreferences.CabinPref = oCabinPref; } } } catch { } #endregion #region [ TPA_EXTENSIONS ] OTA_AirAvailRQTravelPreferencesTPA_Extensions oTravelPreferencesTPA_Extensions = new OTA_AirAvailRQTravelPreferencesTPA_Extensions(); OTA_AirAvailRQTravelPreferencesTPA_ExtensionsDirectAccess oDirectAccess = new OTA_AirAvailRQTravelPreferencesTPA_ExtensionsDirectAccess(); oDirectAccess.Ind = false; oTravelPreferencesTPA_Extensions.DirectAccess = oDirectAccess; List <string> lsNoAerolineas = vo_OTA_AirLowFareSearchLLSRQ.LsExcluirAerolinea; if (lsNoAerolineas != null) { int iContNoAerolineas = 0; OTA_AirAvailRQTravelPreferencesTPA_ExtensionsExcludeVendorPref[] aOTA_AirLowFareSearchRQTravelPreferencesTPA_ExtensionsExcludeVendorPref = new OTA_AirAvailRQTravelPreferencesTPA_ExtensionsExcludeVendorPref[lsNoAerolineas.Count]; foreach (string sAerolinea in lsNoAerolineas) { OTA_AirAvailRQTravelPreferencesTPA_ExtensionsExcludeVendorPref oAerolinea = new OTA_AirAvailRQTravelPreferencesTPA_ExtensionsExcludeVendorPref(); oAerolinea.Code = sAerolinea; aOTA_AirLowFareSearchRQTravelPreferencesTPA_ExtensionsExcludeVendorPref[iContNoAerolineas] = oAerolinea; iContNoAerolineas++; } oTravelPreferencesTPA_Extensions.ExcludeVendorPref = aOTA_AirLowFareSearchRQTravelPreferencesTPA_ExtensionsExcludeVendorPref; } /*string sViajes = vo_OTA_AirLowFareSearchLLSRQ.SVuelosARetornar; * if (Validaciones.getValidarString(sViajes)) * { * OTA_AirLowFareSearchRQTravelPreferencesTPA_ExtensionsNumTrips oNumTrips = * new OTA_AirLowFareSearchRQTravelPreferencesTPA_ExtensionsNumTrips(); * oNumTrips.Number = sViajes; * oTravelPreferencesTPA_Extensions.NumTrips = oNumTrips; * }*/ oOTA_AirLowFareSearchRQTravelPreferences.TPA_Extensions = oTravelPreferencesTPA_Extensions; oOTA_AirLowFareSearchRQ.TravelPreferences = oOTA_AirLowFareSearchRQTravelPreferences; #endregion #region [ TRAVELERINFORMATION ] #endregion #region [ PRICEREQUESTINFORMATION ] #endregion #region [ TPA_EXTENSIONS ] #endregion OTA_AirAvailService oOTA_AirLowFareSearchService = new OTA_AirAvailService(); oOTA_AirLowFareSearchService.MessageHeaderValue = Mensaje_; oOTA_AirLowFareSearchService.SecurityValue = Seguridad_; oOTA_AirLowFareSearchService.Url = objvo_Credentials.UrlWebServices; oOTA_AirLowFareSearchRS = oOTA_AirLowFareSearchService.OTA_AirAvailRQ(oOTA_AirLowFareSearchRQ); // XML //string pathXML = clsValidaciones.XMLDatasetCrea() + "OTA_AirAvailRQ.xml"; //XmlSerializer SerializerRQ = new XmlSerializer(typeof(OTA_AirAvailRQ.OTA_AirAvailRQ)); //StreamWriter WriterRQ = new StreamWriter(pathXML); //try //{ // SerializerRQ.Serialize(WriterRQ, oOTA_AirLowFareSearchRQ); //} //catch //{ // WriterRQ.Flush(); // WriterRQ.Close(); //} //pathXML = clsValidaciones.XMLDatasetCrea() + "OTA_AirAvailRS.xml"; //XmlSerializer SerializerRS = new XmlSerializer(typeof(OTA_AirAvailRS)); //StreamWriter WriterRS = new StreamWriter(pathXML); //try //{ // SerializerRS.Serialize(WriterRS, oOTA_AirLowFareSearchRS); //} //catch //{ // WriterRS.Flush(); // WriterRS.Close(); //} //termina XML if (oOTA_AirLowFareSearchRS.Errors != null) { cParametros.Id = 0; cParametros.Code = oOTA_AirLowFareSearchRS.Errors.Error.ErrorCode; cParametros.Info = oOTA_AirLowFareSearchRS.Errors.Error.ErrorInfo.Message; cParametros.Message = oOTA_AirLowFareSearchRS.Errors.Error.ErrorMessage; cParametros.Severity = oOTA_AirLowFareSearchRS.Errors.Error.Severity; cParametros.Complemento = "HostCommand: " + oOTA_AirLowFareSearchRS.TPA_Extensions.HostCommand; cParametros.Metodo = "getBusqueda"; consulta.AppendLine("Credenciales: "); try { if (objvo_Credentials != null) { consulta.AppendLine("User: "******"Password: "******"Ipcc: " + objvo_Credentials.Ipcc); consulta.AppendLine("Pcc: " + objvo_Credentials.Pcc); consulta.AppendLine("QNumber: " + objvo_Credentials.QNumber); consulta.AppendLine("Dominio: " + objvo_Credentials.Dominio); consulta.AppendLine("Session Sabre: " + Session_.ToString()); consulta.AppendLine("Url Sabre: " + objvo_Credentials.UrlWebServices); } } catch { } cParametros.Tipo = clsTipoError.WebServices; ExceptionHandled.Publicar(cParametros); } else { cParametros.Id = 1; cParametros.TipoLog = Enum_Error.Transac; cParametros.Message = oOTA_AirLowFareSearchRS.Success; cParametros.Metodo = "getBusqueda"; cParametros.Complemento = "HostCommand: " + oOTA_AirLowFareSearchRS.TPA_Extensions.HostCommand; cParametros.Tipo = clsTipoError.WebServices; cParametros.Severity = clsSeveridad.Moderada; consulta.AppendLine("Credenciales: "); try { if (objvo_Credentials != null) { consulta.AppendLine("User: "******"Password: "******"Ipcc: " + objvo_Credentials.Ipcc); consulta.AppendLine("Pcc: " + objvo_Credentials.Pcc); consulta.AppendLine("QNumber: " + objvo_Credentials.QNumber); consulta.AppendLine("Dominio: " + objvo_Credentials.Dominio); consulta.AppendLine("Session Sabre: " + Session_.ToString()); consulta.AppendLine("Url Sabre: " + objvo_Credentials.UrlWebServices); } } catch { } cParametros.TargetSite = consulta.ToString(); ExceptionHandled.Publicar(cParametros); vo_OTA_AirLowFareSearchLLSRQ.Ruta++; clsSesiones.setParametrosAirBargain ( vo_OTA_AirLowFareSearchLLSRQ ); } } } catch (Exception Ex) { cParametros.Id = 0; cParametros.Message = Ex.Message; cParametros.StackTrace = Ex.StackTrace; cParametros.Source = Ex.Source; cParametros.TargetSite = Ex.TargetSite.ToString(); cParametros.Severity = clsSeveridad.Alta; cParametros.Metodo = "getBusqueda"; cParametros.Tipo = clsTipoError.WebServices; ExceptionHandled.Publicar(cParametros); } return(oOTA_AirLowFareSearchRS); }