static public async Task <PingRQResponse> OTA_PingRQ(string usernameAuthenticate, string passwordAuthenticate) { PingRQResponse response = null; try { PmsXchangeServiceClient service = new AsyncServiceConnection().service; OTA_PingRQ body = new OTA_PingRQ() { Version = 1.0M, EchoToken = Guid.NewGuid().ToString() /* Echo token must be unique.*/, TimeStamp = DateTime.Now, TimeStampSpecified = true, EchoData = "good echo" }; // // Send an asynchronous ping request. // response = await service.PingRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), body).ConfigureAwait(false); } catch (Exception ex) { // // Add a single error block to the response with a processing exception in case of an unusual error condition. // response = new PingRQResponse(); response.OTA_PingRS = new OTA_PingRS(); response.OTA_PingRS.Items = new object[] { ProcessingException(ex) }; } return(response); }
// // HERE IS THE SIMPLEST EXAMPLE OF A CALL TO SITEMINDER PMSXCHANGE. THIS CLICK HANDLER FOR THE "PING" BUTTON // WILL SEND A PING WITH AUTHENTICATION INFO AND CHECK IF THE SERVER IS ALIVE. // private async void button_Ping_Click(object sender, RoutedEventArgs e) { WriteResponseLine(string.Format("Sending OTA_PingRQ...")); textBlock_Ping.Text = "Sending..."; PingRQResponse pingResponse = await OTA_PingRQ(username, password); if (pingResponse.OTA_PingRS.Items[0].GetType() == typeof(SuccessType)) { textBlock_Ping.Text = pingResponse.OTA_PingRS.Items[1].ToString(); WriteResponseLine(string.Format("OTA_PingRS success!")); } else { string timestamp = pingResponse.OTA_PingRS.TimeStamp.ToString(); ErrorsType errors = (ErrorsType)pingResponse.OTA_PingRS.Items[0]; foreach (var error in errors.Error) { textBlock_Ping.Text = "Error"; WriteResponseLine(string.Format("OTA_PingRS error - Timestamp: {2}, Type: {0}, Value: {1}", error.Type, error.Value, timestamp)); } } WriteResponseLine(string.Format("")); }
private async void Button_Ping_Click(object sender, RoutedEventArgs e) { //OTA_ResRetrieveRS reservationsResponse = API.OTA_ReadRQ(pmsID, username, password, hotelCode, ResStatus.All); PingRQResponse pingResponse = await API.OTA_PingRS(username, password); if (pingResponse.OTA_PingRS.Items[0].GetType() == typeof(SuccessType)) { string echo = pingResponse.OTA_PingRS.Items[1].ToString(); } else { ErrorsType errors = (ErrorsType)pingResponse.OTA_PingRS.Items[0]; foreach (var error in errors.Error) { } } //ReservationError resErr = new ReservationError(ERR.Hotel_not_active, EWT.Processing_exception, "hello"); }
static public async Task <PingRQResponse> OTA_PingRS(string usernameAuthenticate, string passwordAuthenticate) { PingRQResponse response = null; try { PmsXchangeServiceClient service = ServiceConnection.Instance.service; pmsXchangeService.OTA_PingRQ pingRequestBody = new pmsXchangeService.OTA_PingRQ(); pingRequestBody.Version = 1.0M; pingRequestBody.EchoToken = Guid.NewGuid().ToString(); // Echo token must be unique. pingRequestBody.TimeStamp = DateTime.Now; pingRequestBody.TimeStampSpecified = true; pingRequestBody.EchoData = "good echo"; int q = 0; int h = 7 / q; // // Send an asynchronous ping request. // response = await service.PingRQAsync(CreateSecurityHeader(usernameAuthenticate, passwordAuthenticate), pingRequestBody); } catch (Exception ex) { response = new PingRQResponse(); ErrorsType errors = new ErrorsType(); ErrorType [] err1 = new ErrorType[1]; err1[0] = new ErrorType(); err1[0].Type = EWT.Processing_exception.ToString(); err1[0].Value = ex.Message; response.OTA_PingRS = new OTA_PingRS(); response.OTA_PingRS.Items = new object[] { errors }; } return(response); }