Пример #1
0
        public iDealResponse SendRequest(iDealRequest idealRequest, ISignatureProvider signatureProvider, string url,
            IiDealHttpResponseHandler iDealHttpResponseHandler)
        {
            ServicePointManager.ServerCertificateValidationCallback =
                ((sender, certificate, chain, sslPolicyErrors) => true);

            // Create request
            var request = (HttpWebRequest) WebRequest.Create(url);
            request.ProtocolVersion = HttpVersion.Version11;
            request.ContentType = "text/xml";
            request.Method = "POST";
            // request.Proxy = new WebProxy("192.168.1.8", 8080);

            // Set content
            string xml = idealRequest.ToXml(signatureProvider);
            byte[] postBytes = Encoding.ASCII.GetBytes(xml);

            // Send
            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(postBytes, 0, postBytes.Length);
            }

            // Return result
            using (WebResponse response = request.GetResponse())
            {
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    return iDealHttpResponseHandler.HandleResponse(reader.ReadToEnd(), signatureProvider);
                }
            }
        }
        public iDealResponse SendRequest(iDealRequest idealRequest, ISignatureProvider signatureProvider, string url, IiDealHttpResponseHandler iDealHttpResponseHandler)
        {
            // Create request
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.ProtocolVersion = HttpVersion.Version11;
            request.ContentType = "text/xml";
            request.Method = "POST";

            // Set content
            var postBytes = Encoding.ASCII.GetBytes(idealRequest.ToXml(signatureProvider));

            // Send
            var requestStream = request.GetRequestStream();
            requestStream.Write(postBytes, 0, postBytes.Length);
            requestStream.Close();

            // Return result
            var response = (HttpWebResponse)request.GetResponse();
            return iDealHttpResponseHandler.HandleResponse(new StreamReader(response.GetResponseStream()).ReadToEnd(), signatureProvider);
        }