public T Get <T>(string url, string username, string password, bool isSecureConnection) where T : new() { T _result = new T(); HttpResponseMessage response = null; var tsk = GetAsync(url, username, password, isSecureConnection).ContinueWith(x => { response = x.Result; }); tsk.Wait(); var content = response.Content.ReadAsStringAsync().Result; return(XMLService.Deserialize <T>(content)); }
public T Post <T>(string url, string username, string password, bool isSecureConnection, object content, string soapAction = "", bool debug = false) where T : new() { T _result = new T(); HttpResponseMessage response = null; var tsk = PostAsync(url, username, password, isSecureConnection, content, soapAction, debug).ContinueWith(x => { response = x.Result; }); tsk.Wait(); var respContent = response.Content.ReadAsStringAsync().Result; if (debug) { var folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\DHLDE_Debug"; var filename = "Res-DHLde-" + DateTime.Now.ToString("yyyy-MM-dd") + "-" + Guid.NewGuid().ToString(); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } var debugFilename = System.IO.Path.Combine(folderPath, filename); System.IO.File.WriteAllText(debugFilename, respContent); } return(XMLService.Deserialize <T>(respContent)); }