Skip to content
Loading
POST to a Cisco IP phone
  • Do you have any experience with the WebClient or WebRequest objects? Check out the documentation around them, they're located in System.Net. Code to do what you've listed above would be: public sealed class CiscoIpPhone { public static string PostPhoneMessage(string url, XmlDocument messageXml) { return PostPhoneMessage(url, messageXml.OuterXml); } public static string PostPhoneMessage(string url, string messageXml) { // create the web request WebRequest request = WebRequest.Create(url); // get the Request stream. // we need to write variables to this for the post // set the method to POST Stream stm = request.GetRequestStream(); request.Method = "POST"; // write the xml to the stream StreamWriter sw = new StreamWriter(stm); sw.Write("XML="); sw.Write(messageXml); // set credentials to allow only certain users the ability to do this // req.Credentials = not implemented; // send the request WebResponse response = request.GetResponse(); StreamReader sr = new StreamReader(response.GetResponseStream()); // Clean up by nulling items on the stack // this keeps the garbage collector (GC) from being forced to dump items but reduces the memory they need // until the next GC cleanup sw = null; sr = null; // return the response data sent by the phone // (remember, anything tcp/ip has a response) return sr.ReadToEnd(); } }
    0