예제 #1
0
        public T Execute <T>(IAopRequest <T> request, string accessToken, string appAuthToken) where T : AopResponse
        {
            if (string.IsNullOrEmpty(this.charset))
            {
                this.charset = "utf-8";
            }

            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = Version;
            }

            // 添加协议级请求参数
            AopDictionary txtParams = new AopDictionary(request.GetParameters());

            // 序列化BizModel
            txtParams = SerializeBizModel(txtParams, request);

            txtParams.Add(METHOD, request.GetApiName());
            txtParams.Add(VERSION, apiVersion);
            txtParams.Add(APP_ID, appId);
            txtParams.Add(FORMAT, format);
            txtParams.Add(TIMESTAMP, DateTime.Now);
            txtParams.Add(ACCESS_TOKEN, accessToken);
            txtParams.Add(SIGN_TYPE, signType);
            txtParams.Add(TERMINAL_TYPE, request.GetTerminalType());
            txtParams.Add(TERMINAL_INFO, request.GetTerminalInfo());
            txtParams.Add(PROD_CODE, request.GetProdCode());
            txtParams.Add(CHARSET, charset);


            if (!string.IsNullOrEmpty(request.GetNotifyUrl()))
            {
                txtParams.Add(NOTIFY_URL, request.GetNotifyUrl());
            }

            if (!string.IsNullOrEmpty(appAuthToken))
            {
                txtParams.Add(APP_AUTH_TOKEN, appAuthToken);
            }


            if (request.GetNeedEncrypt())
            {
                if (string.IsNullOrEmpty(txtParams[BIZ_CONTENT]))
                {
                    throw new AopException("api request Fail ! The reason: encrypt request is not supported!");
                }

                if (string.IsNullOrEmpty(this.encyptKey) || string.IsNullOrEmpty(this.encyptType))
                {
                    throw new AopException("encryptType or encryptKey must not null!");
                }

                if (!"AES".Equals(this.encyptType))
                {
                    throw new AopException("api only support Aes!");
                }

                string encryptContent = AopUtils.AesEncrypt(this.encyptKey, txtParams[BIZ_CONTENT], this.charset);
                txtParams.Remove(BIZ_CONTENT);
                txtParams.Add(BIZ_CONTENT, encryptContent);
                txtParams.Add(ENCRYPT_TYPE, this.encyptType);
            }

            // 添加签名参数
            txtParams.Add(SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset, this.keyFromFile, signType));



            // 是否需要上传文件
            string body;


            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          uRequest   = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters());
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, fileParams, this.charset);
            }
            else
            {
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, this.charset);
            }

            T rsp = null;
            IAopParser <T> parser = null;

            if ("xml".Equals(format))
            {
                parser = new AopXmlParser <T>();
                rsp    = parser.Parse(body, charset);
            }
            else
            {
                parser = new AopJsonParser <T>();
                rsp    = parser.Parse(body, charset);
            }

            ResponseParseItem item = parseRespItem(request, body, parser, this.encyptKey, this.encyptType, charset);

            rsp = parser.Parse(item.realContent, charset);

            CheckResponseSign(request, item.respContent, rsp.IsError, parser, this.alipayPublicKey, this.charset, signType, this.keyFromFile);

            return(rsp);
        }
예제 #2
0
        public T pageExecute <T>(IAopRequest <T> request, string accessToken, string appAuthToken, string reqMethod) where T : AopResponse
        {
            if (string.IsNullOrEmpty(this.charset))
            {
                this.charset = "utf-8";
            }

            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = Version;
            }

            AopDictionary txtParams = new AopDictionary(request.GetParameters());

            // 序列化BizModel
            txtParams = SerializeBizModel(txtParams, request);

            // 添加协议级请求参数
            txtParams.Add(AlipayConstants.METHOD, request.GetApiName());
            txtParams.Add(AlipayConstants.VERSION, apiVersion);
            txtParams.Add(AlipayConstants.ALIPAY_SDK, SDK_VERSION);
            txtParams.Add(AlipayConstants.APP_ID, appId);
            txtParams.Add(AlipayConstants.FORMAT, format);
            txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now);
            txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken);
            txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken);
            txtParams.Add(AlipayConstants.SIGN_TYPE, signType);
            txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType());
            txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo());
            txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode());
            txtParams.Add(AlipayConstants.NOTIFY_URL, request.GetNotifyUrl());
            txtParams.Add(AlipayConstants.CHARSET, this.charset);
            txtParams.Add(AlipayConstants.RETURN_URL, request.GetReturnUrl());
            if (certEnvironment != null)
            {
                txtParams.Add(AlipayConstants.ALIPAY_ROOT_CERT_SN, certEnvironment.RootCertSN);
                txtParams.Add(AlipayConstants.APP_CERT_SN, certEnvironment.AppCertSN);
            }
            //字典排序
            IDictionary <string, string> sortedTxtParams = new SortedDictionary <string, string>(txtParams, StringComparer.Ordinal);

            txtParams = new AopDictionary(sortedTxtParams);

            // 排序返回字典类型添加签名参数
            txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(sortedTxtParams, privateKeyPem, this.charset, this.keyFromFile, this.signType));

            // 是否需要上传文件
            string body;

            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          uRequest   = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters());
                body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, fileParams, this.charset);
            }
            else
            {
                if (reqMethod.Equals("GET"))
                {
                    //拼接get请求的url
                    string tmpUrl = serverUrl;
                    if (txtParams != null && txtParams.Count > 0)
                    {
                        if (tmpUrl.Contains("?"))
                        {
                            tmpUrl = tmpUrl + "&" + WebUtils.BuildQuery(txtParams, charset);
                        }
                        else
                        {
                            tmpUrl = tmpUrl + "?" + WebUtils.BuildQuery(txtParams, charset);
                        }
                    }
                    body = tmpUrl;
                }
                else
                {
                    //输出post表单
                    body = BuildHtmlRequest(txtParams, reqMethod, reqMethod);
                }
            }

            T rsp = null;
            IAopParser <T> parser = null;

            if ("xml".Equals(format))
            {
                parser = new AopXmlParser <T>();
                rsp    = parser.Parse(body, charset);
            }
            else
            {
                parser = new AopJsonParser <T>();
                rsp    = parser.Parse(body, charset);
            }

            return(rsp);
        }
예제 #3
0
        public T pageExecute <T>(IAopRequest <T> request, string accessToken, string reqMethod) where T : AopResponse
        {
            if (string.IsNullOrEmpty(this.charset))
            {
                this.charset = "utf-8";
            }

            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = Version;
            }

            AopDictionary txtParams = new AopDictionary(request.GetParameters());

            // 序列化BizModel
            txtParams = SerializeBizModel(txtParams, request);

            System.Text.StringBuilder xmlData = new System.Text.StringBuilder();


            // 添加协议级请求参数
            //AopDictionary txtParams = new AopDictionary(request.GetParameters());
            txtParams.Add(METHOD, request.GetApiName());
            txtParams.Add(VERSION, apiVersion);
            txtParams.Add(APP_ID, appId);
            txtParams.Add(FORMAT, format);
            txtParams.Add(TIMESTAMP, DateTime.Now);
            txtParams.Add(ACCESS_TOKEN, accessToken);
            txtParams.Add(SIGN_TYPE, signType);
            txtParams.Add(TERMINAL_TYPE, request.GetTerminalType());
            txtParams.Add(TERMINAL_INFO, request.GetTerminalInfo());
            txtParams.Add(PROD_CODE, request.GetProdCode());
            txtParams.Add(NOTIFY_URL, request.GetNotifyUrl());
            txtParams.Add(CHARSET, this.charset);
            //txtParams.Add(RETURN_URL, this.return_url);
            txtParams.Add(RETURN_URL, request.GetReturnUrl());
            //字典排序
            IDictionary <string, string> sortedTxtParams = new SortedDictionary <string, string>(txtParams);

            txtParams = new AopDictionary(sortedTxtParams);
            // 排序返回字典类型添加签名参数
            txtParams.Add(SIGN, AopUtils.SignAopRequest(sortedTxtParams, privateKeyPem, this.charset, this.keyFromFile, this.signType));

            // 是否需要上传文件
            string body;

            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          uRequest   = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters());
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, fileParams, this.charset);
            }
            else
            {
                if (reqMethod.Equals("GET"))
                {
                    //直接调用DoGet方法请求
                    //body=webUtils .DoGet (this.serverUrl ,txtParams ,this.charset);
                    //拼接get请求的url
                    string tmpUrl = serverUrl;
                    if (txtParams != null && txtParams.Count > 0)
                    {
                        if (tmpUrl.Contains("?"))
                        {
                            tmpUrl = tmpUrl + "&" + Aop.Api.Util.WebUtils.BuildQuery(txtParams, charset);
                        }
                        else
                        {
                            tmpUrl = tmpUrl + "?" + Aop.Api.Util.WebUtils.BuildQuery(txtParams, charset);
                        }
                    }
                    body = tmpUrl;
                }
                else
                {
                    //直接调用DoPost方法请求
                    // body = webUtils.DoPost(this.serverUrl, txtParams, this.charset);
                    //输出post表单
                    body = BuildHtmlRequest(txtParams, reqMethod, reqMethod);
                }
            }

            T rsp = null;
            IAopParser <T> parser = null;

            if ("xml".Equals(format))
            {
                parser = new AopXmlParser <T>();
                rsp    = parser.Parse(body, charset);
            }
            else
            {
                parser = new AopJsonParser <T>();
                rsp    = parser.Parse(body, charset);
            }

            //验签
            // CheckResponseSign(request, rsp, parser, this.alipayPublicKey, this.charset);
            return(rsp);
        }
예제 #4
0
        public T CertificateExecute <T>(IAopRequest <T> request, string accessToken, string appAuthToken, String targetAppId) where T : AopResponse
        {
            ArgumentValidator.CheckNotNull(certEnvironment, "检测到证书相关参数未初始化,非证书模式下请改为调用Execute。");

            if (string.IsNullOrEmpty(this.charset))
            {
                this.charset = "utf-8";
            }

            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = Version;
            }

            // 添加协议级请求参数
            AopDictionary txtParams = new AopDictionary(request.GetParameters());

            // 序列化BizModel
            txtParams = SerializeBizModel(txtParams, request);

            txtParams.Add(AlipayConstants.METHOD, request.GetApiName());
            txtParams.Add(AlipayConstants.VERSION, apiVersion);
            txtParams.Add(AlipayConstants.ALIPAY_SDK, SDK_VERSION);
            txtParams.Add(AlipayConstants.APP_ID, appId);
            txtParams.Add(AlipayConstants.FORMAT, format);
            txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now);
            txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken);
            txtParams.Add(AlipayConstants.SIGN_TYPE, signType);
            txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType());
            txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo());
            txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode());
            txtParams.Add(AlipayConstants.CHARSET, charset);

            txtParams.Add(AlipayConstants.APP_CERT_SN, certEnvironment.AppCertSN);
            txtParams.Add(AlipayConstants.ALIPAY_ROOT_CERT_SN, certEnvironment.RootCertSN);


            if (!string.IsNullOrEmpty(request.GetNotifyUrl()))
            {
                txtParams.Add(AlipayConstants.NOTIFY_URL, request.GetNotifyUrl());
            }

            if (!string.IsNullOrEmpty(appAuthToken))
            {
                txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken);
            }

            if (!string.IsNullOrEmpty(targetAppId))
            {
                txtParams.Add(AlipayConstants.TARGET_APP_ID, targetAppId);
            }

            if (request.GetNeedEncrypt())
            {
                if (string.IsNullOrEmpty(txtParams[AlipayConstants.BIZ_CONTENT]))
                {
                    throw new AopException("api request Fail ! The reason: encrypt request is not supported!");
                }

                if (string.IsNullOrEmpty(this.encyptKey) || string.IsNullOrEmpty(this.encyptType))
                {
                    throw new AopException("encryptType or encryptKey must not null!");
                }

                if (!"AES".Equals(this.encyptType))
                {
                    throw new AopException("api only support Aes!");
                }

                string encryptContent = AopUtils.AesEncrypt(this.encyptKey, txtParams[AlipayConstants.BIZ_CONTENT], this.charset);
                txtParams.Remove(AlipayConstants.BIZ_CONTENT);
                txtParams.Add(AlipayConstants.BIZ_CONTENT, encryptContent);
                txtParams.Add(AlipayConstants.ENCRYPT_TYPE, this.encyptType);
            }

            // 添加签名参数
            txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset, this.keyFromFile, signType));

            // 是否需要上传文件
            string body;


            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          uRequest   = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters());
                body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, fileParams, this.charset);
            }
            else
            {
                body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, this.charset);
            }

            T rsp;
            IAopParser <T> parser;

            if ("xml".Equals(format))
            {
                parser = new AopXmlParser <T>();
                rsp    = parser.Parse(body, charset);
            }
            else
            {
                parser = new AopJsonParser <T>();
                rsp    = parser.Parse(body, charset);
            }

            ResponseParseItem item = ParseRespItem(request, body, parser, this.encyptKey, this.encyptType, charset);

            rsp = parser.Parse(item.RealContent, charset);


            CheckResponseCertSign(request, item.RespContent, rsp.IsError, parser);

            return(rsp);
        }
예제 #5
0
        public T Execute <T>(IAopRequest <T> request, string accessToken, string appAuthToken) where T : AopResponse
        {
            if (string.IsNullOrEmpty(this.charset))
            {
                this.charset = "utf-8";
            }

            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = Version;
            }

            // 添加协议级请求参数
            AopDictionary txtParams = new AopDictionary(request.GetParameters());

            txtParams.Add(METHOD, request.GetApiName());
            txtParams.Add(VERSION, apiVersion);
            txtParams.Add(APP_ID, appId);
            txtParams.Add(FORMAT, format);
            txtParams.Add(TIMESTAMP, DateTime.Now);
            txtParams.Add(ACCESS_TOKEN, accessToken);
            txtParams.Add(SIGN_TYPE, signType);
            txtParams.Add(TERMINAL_TYPE, request.GetTerminalType());
            txtParams.Add(TERMINAL_INFO, request.GetTerminalInfo());
            txtParams.Add(PROD_CODE, request.GetProdCode());
            txtParams.Add(NOTIFY_URL, request.GetNotifyUrl());
            txtParams.Add(CHARSET, charset);
            txtParams.Add(APP_AUTH_TOKEN, appAuthToken);

            // 添加签名参数
            txtParams.Add(SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset));



            // 是否需要上传文件
            string body;
            //计时器
            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          uRequest   = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters());
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, fileParams, this.charset);
            }
            else
            {
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, this.charset);
            }
            //停止
            sw.Stop();

            T rsp = null;
            IAopParser <T> parser = null;

            if ("xml".Equals(format))
            {
                parser = new AopXmlParser <T>();
                rsp    = parser.Parse(body, charset);
            }
            else
            {
                parser = new AopJsonParser <T>();
                rsp    = parser.Parse(body, charset);
            }

            CheckResponseSign(request, rsp, parser, this.alipayPublicKey, this.charset);
            rsp.RequestUrl     = webUtils.RequestUrl;
            rsp.HttpMethod     = webUtils.HttpMethod;
            rsp.ElapsedTime    = string.Format("{0}ms", sw.ElapsedMilliseconds);//耗费时间
            rsp.RequestContent = webUtils.RequestContent;
            return(rsp);
        }
예제 #6
0
        public T Execute <T>(IAopRequest <T> request, string accessToken) where T : AopResponse
        {
            if (string.IsNullOrEmpty(this.charset))
            {
                this.charset = "utf-8";
            }

            string apiVersion = null;

            if (!string.IsNullOrEmpty(request.GetApiVersion()))
            {
                apiVersion = request.GetApiVersion();
            }
            else
            {
                apiVersion = Version;
            }

            // 添加协议级请求参数
            AopDictionary txtParams = new AopDictionary(request.GetParameters());

            txtParams.Add(METHOD, request.GetApiName());
            txtParams.Add(VERSION, apiVersion);
            txtParams.Add(APP_ID, appId);
            txtParams.Add(FORMAT, format);
            txtParams.Add(TIMESTAMP, DateTime.Now);
            txtParams.Add(ACCESS_TOKEN, accessToken);
            txtParams.Add(SIGN_TYPE, signType);
            txtParams.Add(TERMINAL_TYPE, request.GetTerminalType());
            txtParams.Add(TERMINAL_INFO, request.GetTerminalInfo());
            txtParams.Add(PROD_CODE, request.GetProdCode());
            txtParams.Add(CHARSET, charset);

            // 添加签名参数
            txtParams.Add(SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset));



            // 是否需要上传文件
            string body;


            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          uRequest   = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters());
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, fileParams, this.charset);
            }
            else
            {
                body = webUtils.DoPost(this.serverUrl + "?" + CHARSET + "=" + this.charset, txtParams, this.charset);
            }

            T rsp = null;
            IAopParser <T> parser = null;

            if ("xml".Equals(format))
            {
                parser = new AopXmlParser <T>();
                rsp    = parser.Parse(body, charset);
            }
            else
            {
                parser = new AopJsonParser <T>();
                rsp    = parser.Parse(body, charset);
            }

            CheckResponseSign(request, rsp, parser, this.alipayPublicKey, this.charset);

            return(rsp);
        }
        public T Execute <T>(IAopRequest <T> request, string accessToken, string appAuthToken) where T : AopResponse
        {
            if (string.IsNullOrEmpty(charset))
            {
                charset = "utf-8";
            }
            string text = null;

            text = (string.IsNullOrEmpty(request.GetApiVersion()) ? Version : request.GetApiVersion());
            AopDictionary requestParams = new AopDictionary(request.GetParameters());

            requestParams = SerializeBizModel(requestParams, request);
            requestParams.Add("method", request.GetApiName());
            requestParams.Add("version", text);
            requestParams.Add("app_id", appId);
            requestParams.Add("format", format);
            requestParams.Add("timestamp", DateTime.Now);
            requestParams.Add("auth_token", accessToken);
            requestParams.Add("sign_type", signType);
            requestParams.Add("terminal_type", request.GetTerminalType());
            requestParams.Add("terminal_info", request.GetTerminalInfo());
            requestParams.Add("prod_code", request.GetProdCode());
            requestParams.Add("charset", charset);
            if (!string.IsNullOrEmpty(request.GetNotifyUrl()))
            {
                requestParams.Add("notify_url", request.GetNotifyUrl());
            }
            if (!string.IsNullOrEmpty(appAuthToken))
            {
                requestParams.Add("app_auth_token", appAuthToken);
            }
            if (request.GetNeedEncrypt())
            {
                if (string.IsNullOrEmpty(requestParams["biz_content"]))
                {
                    throw new AopException("api request Fail ! The reason: encrypt request is not supported!");
                }
                if (string.IsNullOrEmpty(encyptKey) || string.IsNullOrEmpty(encyptType))
                {
                    throw new AopException("encryptType or encryptKey must not null!");
                }
                if (!"AES".Equals(encyptType))
                {
                    throw new AopException("api only support Aes!");
                }
                string value = AopUtils.AesEncrypt(encyptKey, requestParams["biz_content"], charset);
                requestParams.Remove("biz_content");
                requestParams.Add("biz_content", value);
                requestParams.Add("encrypt_type", encyptType);
            }
            requestParams.Add("sign", AopUtils.SignAopRequest(requestParams, privateKeyPem, charset, keyFromFile, signType));
            string text2;

            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          aopUploadRequest = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams       = AopUtils.CleanupDictionary(aopUploadRequest.GetFileParameters());
                text2 = webUtils.DoPost(serverUrl + "?charset=" + charset, requestParams, fileParams, charset);
            }
            else
            {
                text2 = webUtils.DoPost(serverUrl + "?charset=" + charset, requestParams, charset);
            }
            T val = null;
            IAopParser <T> aopParser = null;

            if ("xml".Equals(format))
            {
                aopParser = new AopXmlParser <T>();
                val       = aopParser.Parse(text2, charset);
            }
            else
            {
                aopParser = new AopJsonParser <T>();
                val       = aopParser.Parse(text2, charset);
            }
            ResponseParseItem responseParseItem = parseRespItem(request, text2, aopParser, encyptKey, encyptType, charset);

            val = aopParser.Parse(responseParseItem.realContent, charset);
            CheckResponseSign(request, responseParseItem.respContent, val.IsError, aopParser, alipayPublicKey, charset, signType, keyFromFile);
            return(val);
        }
        public T pageExecute <T>(IAopRequest <T> request, string accessToken, string reqMethod) where T : AopResponse
        {
            if (string.IsNullOrEmpty(charset))
            {
                charset = "utf-8";
            }
            string text = null;

            text = (string.IsNullOrEmpty(request.GetApiVersion()) ? Version : request.GetApiVersion());
            AopDictionary requestParams = new AopDictionary(request.GetParameters());

            requestParams = SerializeBizModel(requestParams, request);
            StringBuilder stringBuilder = new StringBuilder();

            requestParams.Add("method", request.GetApiName());
            requestParams.Add("version", text);
            requestParams.Add("app_id", appId);
            requestParams.Add("format", format);
            requestParams.Add("timestamp", DateTime.Now);
            requestParams.Add("auth_token", accessToken);
            requestParams.Add("sign_type", signType);
            requestParams.Add("terminal_type", request.GetTerminalType());
            requestParams.Add("terminal_info", request.GetTerminalInfo());
            requestParams.Add("prod_code", request.GetProdCode());
            requestParams.Add("notify_url", request.GetNotifyUrl());
            requestParams.Add("charset", charset);
            requestParams.Add("return_url", request.GetReturnUrl());
            IDictionary <string, string> dictionary = new SortedDictionary <string, string>(requestParams);

            requestParams = new AopDictionary(dictionary);
            requestParams.Add("sign", AopUtils.SignAopRequest(dictionary, privateKeyPem, charset, keyFromFile, signType));
            string body;

            if (request is IAopUploadRequest <T> )
            {
                IAopUploadRequest <T>          aopUploadRequest = (IAopUploadRequest <T>)request;
                IDictionary <string, FileItem> fileParams       = AopUtils.CleanupDictionary(aopUploadRequest.GetFileParameters());
                body = webUtils.DoPost(serverUrl + "?charset=" + charset, requestParams, fileParams, charset);
            }
            else if (reqMethod.Equals("GET"))
            {
                string text2 = serverUrl;
                if (requestParams != null && requestParams.Count > 0)
                {
                    text2 = ((!text2.Contains("?")) ? (text2 + "?" + WebUtils.BuildQuery(requestParams, charset)) : (text2 + "&" + WebUtils.BuildQuery(requestParams, charset)));
                }
                body = text2;
            }
            else
            {
                body = BuildHtmlRequest(requestParams, reqMethod, reqMethod);
            }
            T val = null;
            IAopParser <T> aopParser = null;

            if ("xml".Equals(format))
            {
                aopParser = new AopXmlParser <T>();
                return(aopParser.Parse(body, charset));
            }
            aopParser = new AopJsonParser <T>();
            return(aopParser.Parse(body, charset));
        }