/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(String url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.UserAgent = "MJZSOFT XML RPC 1.0.0 (MJZ HTTP Transport)"; request.KeepAlive = false; request.AllowWriteStreamBuffering = true; Stream stream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(stream, _encoding); _serializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); input.Close(); response.Close(); return(resp); }
/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <param name="timeout">AMount of time in milliseconds to wait for timeout</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(string url, int timeout = 0) { var request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; if (timeout > 0) { request.Timeout = timeout; } var stream = request.GetRequestStream(); var xml = new XmlTextWriter(stream, _encoding); _serializer.Serialize(xml, this); xml.Flush(); xml.Close(); var response = (HttpWebResponse)request.GetResponse(); var input = new StreamReader(response.GetResponseStream()); var resp = (XmlRpcResponse)_deserializer.Deserialize(input); input.Close(); response.Close(); return(resp); }
/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(string url, int timeout = 100000, RemoteCertificateValidationCallback certCallBack = null) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; request.Timeout = timeout; if (certCallBack != null) { request.ServerCertificateValidationCallback = certCallBack; } using (Stream stream = request.GetRequestStream()) using (XmlTextWriter xml = new XmlTextWriter(stream, m_encoding)) { _serializer.Serialize(xml, this); xml.Flush(); } XmlRpcResponse resp; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (StreamReader input = new StreamReader(response.GetResponseStream())) resp = (XmlRpcResponse)_deserializer.Deserialize(input); return(resp); }
/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <param name="timeout">Milliseconds before the connection times out.</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(String url, int timeout) { // Override SSL authentication mechanisms ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; request.Timeout = timeout; Stream stream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(stream, _encoding); _serializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); input.Close(); response.Close(); return(resp); }
/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(String url) { RequestSettings settings = RequestSettings.getInstance(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); settings.Apply(request); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; Stream stream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(stream, _encoding); _serializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); input.Close(); response.Close(); return(resp); }
override public String ToString() { StringWriter strBuf = new StringWriter(); XmlTextWriter xml = new XmlTextWriter(strBuf); xml.Formatting = Formatting.Indented; xml.Indentation = 4; XmlRpcRequestSerializer.Serialize(xml, this); xml.Flush(); xml.Close(); return(strBuf.ToString()); }
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); }
/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(String url) { // Override SSL authentication mechanisms ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); //ServicePointManager.ServerCertificateValidationCallback += // delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) // { return true; }; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; request.KeepAlive = false; request.Timeout = 15000; // miliseconds adjust as you see fit Stream stream = request.GetRequestStream(); XmlTextWriter xml = new XmlTextWriter(stream, _encoding); _serializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader input = new StreamReader(response.GetResponseStream()); XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); input.Close(); response.Close(); return(resp); }
/// <summary>Send the request to the server.</summary> /// <param name="url"><c>String</c> The url of the XML-RPC server.</param> /// <returns><c>XmlRpcResponse</c> The response generated.</returns> public XmlRpcResponse Send(String url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; request.KeepAlive = !_disableKeepAlive; request.Timeout = 30000; using (Stream stream = request.GetRequestStream()) { using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII)) { _serializer.Serialize(xml, this); xml.Flush(); } } XmlRpcResponse resp; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream s = response.GetResponseStream()) { using (StreamReader input = new StreamReader(s)) { string inputXml = input.ReadToEnd(); try { resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml); } catch (Exception e) { RequestResponse = inputXml; throw e; } } } } 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); }