首页 新闻 会员 周边 捐助

微信退款接口连接异常

0
悬赏园豆:10 [已解决问题] 解决于 2015-12-01 17:56

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

部分代码:

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();
                }
瀞默的主页 瀞默 | 初学一级 | 园豆:149
提问于:2015-11-20 14:48
< >
分享
最佳答案
0

微信自带的文档,注意传入参数顺序,签名必须在最后

瀞默 | 初学一级 |园豆:149 | 2015-12-01 17:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册