private string CallWebService() { string url= ""; if (Request.IsLocal) { url = "http://localhost:2111/UPDB2016/Default.asmx/AddNominations"; } string result = ""; string strPost = ""; StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.Timeout = 200000; objRequest.ContentLength = strPost.Length; objRequest.ContentType = "application/x-www-form-urlencoded"; objRequest.KeepAlive = false; try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(strPost); } catch (Exception e) { throw new Exception(e.ToString()); } finally { myWriter.Close(); } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); sr.Close(); } return result; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)