public XmlRpcResponse Send2(String url, String strContent) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); string postData = strContent; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] byte1 = encoding.GetBytes(postData); // Set the content type of the data being posted. request.ContentType = "text/xml"; request.Method = "POST"; // Set the content length of the string being posted. // request.ContentLength = postData.Length; WebProxy myProxy = new WebProxy(); try { if (ConfigurationManager.AppSettings["ProxyAddress"].ToString() != "") { string proxyAddress = ConfigurationManager.AppSettings["ProxyAddress"].ToString(); if (proxyAddress.Length > 0) { Uri newUri = new Uri(proxyAddress); // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set. myProxy.Address = newUri; // Create a NetworkCredential object and associate it with the Proxy property of request object. myProxy.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ProxyUser"].ToString(), ConfigurationManager.AppSettings["ProxyPass"].ToString()); request.Proxy = myProxy; } } } catch (Exception) { } Stream newStream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(newStream, _encoding); XmlRpcRequestSerializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = XmlRpcResponseDeserializer.Parse(input); input.Close(); response.Close(); return(resp); }
public XmlRpcResponse Send(String url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "test/xml"; WebProxy myProxy = new WebProxy(); try { if (ConfigurationManager.AppSettings["ProxyAddress"].ToString() != "") { string proxyAddress = ConfigurationManager.AppSettings["ProxyAddress"].ToString(); if (proxyAddress.Length > 0) { Uri newUri = new Uri(proxyAddress); // Associate the newUri object to 'myProxy' object so that new myProxy settings can be set. myProxy.Address = newUri; // Create a NetworkCredential object and associate it with the Proxy property of request object. myProxy.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ProxyUser"].ToString(), ConfigurationManager.AppSettings["ProxyPass"].ToString()); request.Proxy = myProxy; } } } catch (Exception) { } //request.AllowWriteStreamBuffering = true; //request.ReadWriteTimeout = 1000; //request.Timeout = 1000; //request.ContentLength = strContent.Length; Stream stream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(stream, _encoding); XmlRpcRequestSerializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = XmlRpcResponseDeserializer.Parse(input); input.Close(); response.Close(); return(resp); }
public XmlRpcResponse Send(String url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "test/xml"; Stream stream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(stream, _encoding); XmlRpcRequestSerializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = XmlRpcResponseDeserializer.Parse(input); input.Close(); response.Close(); return(resp); }