示例#1
0
            public void sendGetAuthorizeAnswer()
            {
                string output = "";

                try
                {
                    var res = connector.GetAuthorizeAnswer(getAuthorizeAnswerParams);

                    foreach (var key in res.Keys)
                    {
                        Console.WriteLine("- " + key + ": " + res[key]);

                        if (key.Equals("Payload"))
                        {
                            System.Xml.XmlNode[] aux = (System.Xml.XmlNode[])res["Payload"];
                            if (aux != null)
                            {
                                for (int i = 0; i < aux.Count(); i++)
                                {
                                    System.Xml.XmlNodeList inner = aux[i].ChildNodes;
                                    for (int j = 0; j < inner.Count; j++)
                                    {
                                        Console.WriteLine("     " + inner.Item(j).Name + " : " + inner.Item(j).InnerText);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ProtocolError)
                    {
                        WebResponse resp = ex.Response;
                        using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
                        {
                            output += "\r\n" + sr.ReadToEnd() + "\r\n" + ex.Message;
                            //Response.Write(sr.ReadToEnd());
                        }
                    }
                }
                catch (Exception ex)
                {
                    output += "\r\n" + ex.Message + "\r\n" + ex.InnerException.Message + "\r\n" + ex.HelpLink;
                }

                Console.WriteLine(output);
            }
示例#2
0
        private Dictionary <String, Object> executeGetAuthorizeAnswer(TPConnector connector, InfoModel info)
        {
            Dictionary <string, string> getAuthorizeAnswerParams = new Dictionary <string, string>();

            info.ResultadoGAA = String.Empty;

            initGetAuthorizeAnswer(getAuthorizeAnswerParams, info);

            var res = new Dictionary <String, Object>();

            try
            {
                res = connector.GetAuthorizeAnswer(getAuthorizeAnswerParams);

                if (res.ContainsKey("StatusCode") && res["StatusCode"] != null)
                {
                    info.StatusCode = res["StatusCode"].ToString();
                }

                if (res.ContainsKey("StatusMessage") && res["StatusMessage"] != null)
                {
                    info.StatusMessage = res["StatusMessage"].ToString();
                }

                foreach (var key in res.Keys)
                {
                    info.ResultadoGAA += "- " + key + ": " + res[key];
                    if (key.Equals("Payload"))
                    {
                        XmlNode[] aux = (XmlNode[])res["Payload"];
                        if (aux != null)
                        {
                            for (int i = 0; i < aux.Length; i++)
                            {
                                XmlNodeList inner = aux[i].ChildNodes;
                                for (int j = 0; j < inner.Count; j++)
                                {
                                    info.ResultadoGAA += "     " + inner.Item(j).Name + " : " + inner.Item(j).InnerText;
                                }
                            }
                        }
                    }
                }
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    WebResponse resp = ex.Response;
                    using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
                    {
                        info.ResultadoGAA = sr.ReadToEnd() + " - " + ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                info.ResultadoGAA = ex.Message + " - " + ex.InnerException.Message + " - " + ex.HelpLink;
            }

            return(res);
        }