/// <summary> /// Asynchronously tries to perform the refresh request. /// </summary> /// <param name="security">The security.</param> /// <param name="conversationId">The conversation identifier.</param> /// <returns>The SOAP result of the Ping response.</returns> public async Task <SoapResult <OTA_PingRS> > TryRefreshAsync(Security security, string conversationId) { OTA_PingRQ request = this.soapServiceFactory.CreatePingRequest(); SWSService service = this.soapServiceFactory.CreatePingService(conversationId, security); var source = new TaskCompletionSource <SoapResult <OTA_PingRS> >(); service.OTA_PingRQCompleted += (s, e) => { if (SoapHelper.HandleErrors(e, source)) { if (e.Result.Items.Any()) { ErrorsType error = e.Result.Items[0] as ErrorsType; if (error != null && error.Error != null && error.Error.Length > 0) { source.TrySetResult(SoapResult <OTA_PingRS> .Error(error.Error.First())); return; } } source.TrySetResult(SoapResult <OTA_PingRS> .Success(e.Result)); } }; service.OTA_PingRQAsync(request); return(await source.Task); }
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); }
public static RequestPing QueryRequestPingAbg(PingModel objectItem) { //RequestPing var requestPing = new RequestPing(); //RequestPing - OTA_PingRQ var otaPingRq = new OTA_PingRQ(); otaPingRq.EchoToken = Guid.NewGuid().ToString(); otaPingRq.Version = objectItem.Version; //RequestPing - OTA_PingRQ - EchoData otaPingRq.EchoData = objectItem.Message; requestPing.OTA_PingRQ = otaPingRq; return(requestPing); }