cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
504
Views
0
Helpful
1
Replies

HTTP POST to a CISCO 7940 phone

jdenbrock
Level 1
Level 1

I attempting to write a C# Windows Forms app that will automatically dial an internal extension when a buttons is clicked.

On the call manager server the following error is appearing in the event log:

A connection was established and immediately dropped before completing registration. Incomplete registration may indicate a device is rehoming in the middle of registration. The alarm could also indicate a device misconfiguration, database error, or an illegal/unknown device trying to attempt a connection.

Recommended Action: No action is required if this event was issued as a result of a normal device rehome..

Here is the code I'm using:

string xml = "XML=<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\" URL=\"Dial:4014\"></CiscoIPPhoneExecute>";

string fullURL = "http://10.2.23.237/CGI/Execute";

ASCIIEncoding encoding = new ASCIIEncoding();

byte[] data = encoding.GetBytes(xml);

string userNameAndPassword = "jdoe:12345";

byte[] bytes = encoding.GetByte(userNameAndPassword);

string userNameAndPasswordInBase64 = Convert.ToBase64String(bytes);

HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(fullURL);

myHttpWebRequest.Method = "POST";

myHttpWebRequest.ContentType="application/x-www-form-urlencoded";

myHttpWebRequest.ContentLength = data.Length;

myHttpWebRequest.Headers.Add("Authorization", "Basic " + userNameAndPasswordInBase64);

Stream requestStream = myHttpWebRequest.GetRequestStream();

requestStream.Write(data, 0, data.Length);

HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

Stream receiveStream = myHttpWebResponse.GetResponseStream();

StreamReader readStream = new StreamReader(receiveStream, encoding);

Char[] read = new Char[256];

int count = readStream.Read( read, 0, 256 );

StringBuilder sb = new StringBuilder();

while (count > 0)

{

String str = new String(read, 0, count);

sb.Append( str);

count = readStream.Read(read, 0, 256);

}

requestStream.Close();

receiveStream.Close();

readStream.Close();

myHttpWebResponse.Close();

string responseData = sb.ToString ();

1 Reply 1

stephan.steiner
Spotlight
Spotlight

I take it that if you send your XML to the phone via your standard test html page that you open in a browser (this is THE debugging thing to do.. knowing your XML is being handled properly should always be your first stop in the error determination process) the phone does what you ask it to?

Personally I'm not really a 100% on this whole URL/URI thing, but I successfully managed to make my IPC (no phones around on homeoffice day) dial a number at work using the following XML code (launched from a browser page (html posted below).

Here's the html page.. adjust your IP address accordingly

http://192.168.1.34/CGI/Execute" Method="POST">


I also assume your authentication is in order and using your code you manage to send other ExecuteItems that are properly executed?