微信退款接口连接异常
2015-11-20 来自:麦麦麦 0 人回应

根据微信退款接口传入了指定参数,访问地址后,抛出‘基础连接已经关闭: 连接被意外关闭‘异常。查看报文发现一切正常。

部分代码:

if (this.refundUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))
                {
                    ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
                }

                request = (HttpWebRequest)WebRequest.Create(this.refundUrl);
                request.Method = "POST";
                request.Timeout = 20000;
                request.UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36";
              
                //设置POST的数据类型和长度
                request.ContentType = "text/xml";
                byte[] data = System.Text.Encoding.UTF8.GetBytes(parameters);
                request.ContentLength = data.Length;

                //往服务器写入数据
                using (Stream reqStream = request.GetRequestStream())
                {
                    reqStream.Write(data, 0, data.Length);
                }

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                //获取服务端返回
                response = (HttpWebResponse)request.GetResponse();

                //获取服务端返回数据
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    result = reader.ReadToEnd().Trim();
                }
还没有人回应!

您的回应

你还未登陆,不能回应!登陆