static public async Task <ReadRQResponse> OTA_ReadRQ(string pmsID, string usernameAuthenticate, string passwordAuthenticate, string hotelCode, ResStatus resStatus) { ReadRQResponse response = null; try { PmsXchangeServiceClient service = new AsyncServiceConnection().service; OTA_ReadRQ body = new OTA_ReadRQ() { Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique. */, TimeStamp = DateTime.Now, TimeStampSpecified = true, POS = CreatePOS(pmsID) }; OTA_ReadRQReadRequests readRequests = new OTA_ReadRQReadRequests(); OTA_ReadRQReadRequestsHotelReadRequest hotelReadRequest = new OTA_ReadRQReadRequestsHotelReadRequest() { HotelCode = hotelCode }; readRequests.Items = new object[] { hotelReadRequest }; OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria selectionCriteria = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria() { SelectionType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered, SelectionTypeSpecified = true /* Must be set to true, or ReadRQ returns an error.*/ }; if (resStatus != ResStatus.All) { selectionCriteria.ResStatus = resStatus.ToString(); } hotelReadRequest.SelectionCriteria = selectionCriteria; body.ReadRequests = readRequests; // // Send a retrieve reservations request. // response = await service.ReadRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false); } catch (NullReferenceException) { Exception exSetup = new Exception("OTA_NotifReportRQ arguments were not set up properly causing a null reference exception."); response = new ReadRQResponse(); response.OTA_ResRetrieveRS = new OTA_ResRetrieveRS(); response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(exSetup) }; } catch (Exception ex) { response = new ReadRQResponse(); response.OTA_ResRetrieveRS = new OTA_ResRetrieveRS(); response.OTA_ResRetrieveRS.Items = new object[] { ProcessingException(ex) }; } return(response); }
static int ConnectSample() { PmsXchangeService service = new PmsXchangeService(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //The security header is untyped due to the lax processing instruction System.Xml.XmlElement token = doc.CreateElement("UsernameToken"); System.Xml.XmlElement password = doc.CreateElement("Password"); System.Xml.XmlElement username = doc.CreateElement("Username"); System.Xml.XmlText usernameText = doc.CreateTextNode("SPIOrangeTest"); System.Xml.XmlText passwordText = doc.CreateTextNode("YOURPASSWORD"); username.AppendChild(usernameText); password.AppendChild(passwordText); token.AppendChild(username); token.AppendChild(password); System.Xml.XmlElement[] elements = new System.Xml.XmlElement[] { token }; SecurityHeaderType type = new SecurityHeaderType(); service.Security = type; service.Security.Any = elements; OTA_ReadRQ otaReadRQ = new OTA_ReadRQ(); otaReadRQ.Version = 1.0M; OTA_ReadRQReadRequests rr = new OTA_ReadRQReadRequests(); OTA_ReadRQReadRequestsHotelReadRequest hotelR = new OTA_ReadRQReadRequestsHotelReadRequest(); hotelR.HotelCode = "123"; object[] ob = new object[] { hotelR }; rr.Items = ob; OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria crit = new OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteria(); OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType selType = OTA_ReadRQReadRequestsHotelReadRequestSelectionCriteriaSelectionType.Undelivered; crit.SelectionType = selType; crit.SelectionTypeSpecified = true; hotelR.SelectionCriteria = crit; otaReadRQ.ReadRequests = rr; // Retrieve the response Console.WriteLine("About to make request :::"); OTA_ResRetrieveRS resRetrieveRS = service.ReadRQ(otaReadRQ); Console.WriteLine("Received response :::"); //Do further work .... // .... return(0); }