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(); }
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(); }
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(); } }