public async Task CreateAndDeleteClient() { var createRequestObject = new XmlClient() { Name = "TestingClient" + Guid.NewGuid() }; var serializedXml = ResponseParser.Serialize(createRequestObject); Debug.WriteLine("CreateClient XML Request: " + serializedXml); var content = new StringContent(serializedXml); var createResponse = await Connector.Post("client.api/add", content); Assert.AreEqual(HttpStatusCode.OK, createResponse.StatusCode); var responsePayload = await createResponse.Content.ReadAsStringAsync(); Debug.WriteLine("CreateClient XML Response: " + responsePayload); var response = ResponseParser.Deserialize <ClientResponse>(responsePayload); var request = new ClientRequest() { Id = response.Client.Id }; var xml = ResponseParser.Serialize(request); Debug.WriteLine(xml); var deleteRequestContent = new StringContent(xml); var deleteResponse = await Connector.Post("/client.api/delete", deleteRequestContent); Assert.AreEqual(HttpStatusCode.OK, deleteResponse.StatusCode); }
public Task GetRootWithRefAndNoMetaXML_Sync() => Test((host, pipeline) => { var result = new XmlClient(ClientDiagnostics, pipeline, host).GetComplexTypeRefNoMeta(); var value = result.Value; Assert.AreEqual("else", value.Something); Assert.AreEqual("myid", value.RefToModel.ID); });
public ActionResult GetInboundXml(int id) { InboundXmlUpdateModel model = new InboundXmlUpdateModel(); ErrorLog error = new ErrorLog(); error.CEA_Xml_id = id; using (var client = new HttpClient()) { try { var token = Request.Cookies["access_token"].Value; client.BaseAddress = new Uri(ConfigurationManager.AppSettings["ApiUrl"].ToString()); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); //HTTP GET var responseTask = client.PostAsJsonAsync <ErrorLog>("GetXmlFromCeaXmlId", error); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { InboundXmlModel inboundModel = new InboundXmlModel(); var readTask = result.Content.ReadAsAsync <InboundXmlModel>(); readTask.Wait(); if (readTask.Result.InboundXMLString != null && readTask.Result.InboundXMLString != " ") { inboundModel.InboundXMLString = readTask.Result.InboundXMLString; inboundModel.XmlElements = XmlClient.GetAllUniqueElements(inboundModel.InboundXMLString); model.ActivityLogPolicyId = id; } else { ModelState.AddModelError(string.Empty, "Inbound XMl Not Found"); } model.InboundXmlModel = inboundModel; } else { ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); return(RedirectToAction("ErrorLog")); } } catch (Exception ex) { return(RedirectToAction("_ErrorLog")); } return(PartialView("_XmlEditorPopup", model)); } }
static void Main(string[] args) { XmlDocument request = new XmlDocument(); // Fix for Xml external entity injection violation in fortify report XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Prohibit; settings.XmlResolver = null; XmlReader reader = XmlReader.Create("sample.xml", settings); request.Load(reader); string cybsNamespace = XmlClient.GetRequestNamespace(request); if (cybsNamespace == null) { throw new ApplicationException( "XML document is missing requestMessage"); } try { Console.WriteLine("starting"); XmlDocument reply = XmlClient.RunTransaction(request); SaveOrderState(); ProcessReply(reply, cybsNamespace); } catch (FaultException fe) { //A custom exception created by the Cybersource Client from SaveOrderState(); HandleFaultException(fe, cybsNamespace); } catch (CryptographicException ce) { SaveOrderState(); HandleCryptoException(ce); } catch (WebException we) { SaveOrderState(); HandleWebException(we); } catch (Exception e) { SaveOrderState(); HandleException(e); } Console.WriteLine("Press Return to end..."); Console.ReadLine(); }
private void btnGetUsername_Click(object sender, RoutedEventArgs e) { ApiWaiting = new PleaseWait(); ApiWaiting.Title = strings.AccountManager_TokenValidation; ApiWaiting.Owner = this; ApiWaiting.Show(); string token = txtToken.Text; ThreadStart start = delegate() { XmlClient client = new XmlClient(_settings.UserLanguage, token); try { string message; List <string> result = client.GetUsernameByToken(out message); /*for (int i = 1; i < 100; i++) * { * result = client.GetUsernameByToken(out message); * if (!String.IsNullOrEmpty(message)) * { * Dispatcher.Invoke(DispatcherPriority.Background, * new Action<string>(TokenError), * message); * break; * } * }*/ if (result.Count > 0) { Dispatcher.Invoke(DispatcherPriority.Background, new Action <List <string> >(InitializeUsernameList), result); } else { Dispatcher.Invoke(DispatcherPriority.Background, new Action <string>(TokenError), message); } } catch { Dispatcher.Invoke(DispatcherPriority.Background, new Action <List <string> >(InitializeUsernameList), null); } }; new System.Threading.Thread(start).Start(); }
static void Main(string[] args) { XmlDocument request = new XmlDocument(); request.Load(args.Length == 1 ? args[0] : "sample.xml"); string cybsNamespace = XmlClient.GetRequestNamespace(request); if (cybsNamespace == null) { throw new ApplicationException( "XML document is missing requestMessage"); } try { Console.WriteLine("starting"); XmlDocument reply = XmlClient.RunTransaction(request); SaveOrderState(); ProcessReply(reply, cybsNamespace); } catch (FaultException fe) { //A custom exception created by the Cybersource Client from SaveOrderState(); HandleFaultException(fe, cybsNamespace); } catch (CryptographicException ce) { SaveOrderState(); HandleCryptoException(ce); } catch (WebException we) { SaveOrderState(); HandleWebException(we); } catch (Exception e) { SaveOrderState(); HandleException(e); } Console.WriteLine("Press Return to end..."); Console.ReadLine(); }
private void ONLCompetitionSettings_Load(object sender, EventArgs e) { try { SqlCommand cmd = new SqlCommand(); if (cn.State != ConnectionState.Open) { cn.Open(); } cmd.CommandText = "SELECT remoteString FROM CompetitionData(NOLOCK)"; cmd.Connection = cn; XmlClientWrapper wrapper; long? compIDforService = StaticClass.ParseServString(cmd.ExecuteScalar() as string, out wrapper); if (wrapper != null) { compIDforService = wrapper.CompetitionId; client = wrapper.CreateClient(cn); } if (compIDforService == null || !compIDforService.HasValue) { MessageBox.Show("Не настроен доступ к веб-службам или не выбрано соревнование"); this.Close(); return; } compID = compIDforService.Value; service = new ClimbingService(); paramsGrid.Service = service; paramsGrid.compID = compID; paramsGrid.LoadData(); string str = service.GetParamValue(Constants.PDB_COMP_VIDEO, compID); str = (str == null) ? String.Empty : str.Trim().ToLower(); cbVideoOld = str.Equals("true") || str.Equals("1"); cbVideo.Checked = cbVideoOld; } catch (Exception ex) { MessageBox.Show("Не удалось запустить форму настройки соревнований:\r\n" + ex.Message); this.Close(); return; } }
public loadAgr(bool useCurrent, bool loadPhoto, bool loadJudges, long?compForService, XmlClient client, MainForm.AfetrStopCallBack callback, SqlConnection _cn) { SqlConnection cn = new SqlConnection(_cn.ConnectionString); if (cn.State != ConnectionState.Open) { cn.Open(); } this.Client = new XmlClient(client.BaseUrl, client.CompId, SecurityOperations.CreateSigningDelegate(cn), SecurityOperations.GetPassword(cn)) { Proxy = client.Proxy, Timeout = client.Timeout }; this.useCurrent = useCurrent; this.loadJudges = loadJudges; this.loadPhoto = loadPhoto; this.Callback = callback; this.compForService = compForService; }
public EmployeesModel() { string baseAddress = ConfigurationManager.AppSettings["BaseAddress"]; XmlClient = XmlClientManager.GetClient(baseAddress); }
static AppSecurity() { string baseAddress = ConfigurationManager.AppSettings["BaseAddress"]; XmlClient = XmlClientManager.GetClient(baseAddress); }
public ClientDashboard(CIVAccount account) { InitializeComponent(); DataContext = account; // Construction de l'interface foreach (DisplayInfoTypes element in ProgramSettings.Instance.Display) { spMainContainer.Children.Insert(spMainContainer.Children.Count, DisplayInfoFactory.Create(element, account)); } IsWorking = false; Messages = new ObservableCollection <ScreenMessage>(); ApiClient = new XmlClient(ProgramSettings.Instance.UserLanguage, account.Account.Token, account.Account.Username); ApiClient.OnReadDailyWiredUsage += ReadDailyWiredUsage; ApiClient.OnError += ApiClientError; ApiClient.OnDownloadData += OnDownloadData; ApiClient.OnDownloadDataEnd += OnDownloadDataEnd; ApiClient.OnDownloadHistory += OnDownloadHistory; ApiClient.OnDownloadHistoryEnd += OnDownloadHistoryEnd; // Déclenche le rafraichissement du UI Account = account; if (Account.Account.LastUpdate == DateTime.MinValue) { // Mettre un délai aléatoire LaunchUpdate(false); } else { ShowLastUpdate(); } if (ProgramSettings.Instance.EmailSMTP.Active && Account.SendMail && !String.IsNullOrEmpty(Account.MailSubject) && !String.IsNullOrEmpty(Account.MailTemplate)) { btnSendMail.Visibility = System.Windows.Visibility.Visible; } else { btnSendMail.Visibility = System.Windows.Visibility.Collapsed; } if (DataBaseFactory.Instance.IsAvailable) { List <DailyUsageBO> usages = DailyUsageDAO.Instance.UsageByPeriod(account.Account.Username, DateTime.Now.Date, DateTime.Now.Date); if (usages.Count > 0) { Account.Account.CurrentDayUpload = usages[0].Upload; Account.Account.CurrentDayDownload = usages[0].Download; } } }