Exemplo n.º 1
0
 public ActionResult ViewXml()
 {
     var response = new UssdResponseMessage { TransactionId = "TransactionId", TransactionTime = DateTime.UtcNow.ToString("o"), action = "end", USSDResponseString = "Your account is blah blah blah!" };
     var xmlForm = new USSDXMLWriter(response).GenerateXml();
     ViewBag.Message = xmlForm;
     return View();
 }
Exemplo n.º 2
0
 public void SendUssdResponse(string httpresponse)
 {
     //Remember to format it in xml first
     httpresponse = httpresponse.Replace("©", "\n");
     var responseObj = GetObjectFromJson(httpresponse);
     var xmlResponse = new USSDXMLWriter(responseObj).GenerateXml();
     string url = ConfigurationManager.AppSettings["EtUrl"].ToString(CultureInfo.InvariantCulture);
     var webRequest = (HttpWebRequest)WebRequest.Create(url);
     webRequest.Method = "POST";
     webRequest.ContentType = "text/xml";
     byte[] byteArray = Encoding.UTF8.GetBytes(xmlResponse);
     webRequest.ContentLength = byteArray.Length;
     Stream stream = webRequest.GetRequestStream();
     stream.Write(byteArray, 0, byteArray.Length);
     stream.Close();
     WebResponse response = webRequest.GetResponse();
     response.Close();
 }
Exemplo n.º 3
0
        public void XmlRpcCall(string httpResponse)
        {
            httpResponse = httpResponse.Replace("©", "<\br>");
            var responseObj = GetObjectFromJson(httpResponse);
            var xmlResponse = new USSDXMLWriter(responseObj).GenerateXml();
            string url = ConfigurationManager.AppSettings["EtUrl"].ToString(CultureInfo.InvariantCulture);
            var req = (HttpWebRequest)WebRequest.Create(url);
            req.Method = "POST";
            var command = xmlResponse;
            var bytes = Encoding.ASCII.GetBytes(command);
            req.ContentLength = bytes.Length;
            using (var stream = req.GetRequestStream())
            {
                stream.Write(bytes, 0, bytes.Length);
            }

            using (var stream = new StreamReader(req.GetResponse().GetResponseStream()))
            {
                stream.ReadToEnd();
            }
        }