Tuesday, April 8, 2008

I was trying to do a simple thing, i.e., push XML to my Cisco IP Phone, in order to make it display a message and/or display a sound.Theory is simple : POST an XML message to the IP Phone's /CGI/Execute by means of a simple HTTP connection.I decided to use the C# HttpWebRequest object, thinking it's exactly what I needed.

Note : this is a story of a good workaround, not of the solution, I'm still workin' on it, stay tuned.

What I wanted was to post this to my IP Phone :"XML=<ciscoipphoneexecute><executeitem priority="0" url="Play:chime.raw"><executeitem priority="0" url="http://10.10.10.10:8080/textmessage.xml"></executeitem>"

that means : play chime.raw and display the xml returned by a GET from the phone on http://10.10.10.10:8080/textmessage.xml

All I obtained was always a very annoying<CiscoIPPhoneError Number="6" />

I found nothing on this error, as Cisco docs say :

CiscoIPPhoneError

The following list gives possible CiscoIPPhoneError codes:

Error 1 = Error parsing CiscoIPPhoneExecute object

Error 2 = Error framing CiscoIPPhoneResponse object

Error 3 = Internal file error

Error 4 = Authentication error

So I started sniffing the POST from my dev box to the phone observing some strange traffic before sending the POST message.The reason is .NET implementation of the HTTP request, that add an Expect 100-Continue header on the very first packet, and then send the real POST after receiving the 100-Continue from the server (the IP Phone in this case).

You can find a more exhaustive explanation on this here.Note that implementing the solution indicated (set the System.Net.ServicePointManager.Expect100Continue to false) worked not on my code, I'm still workin' on it.

My solution, or workaround if you wish, was to use a simpler object, the MSXML2.XMLHTTPClass class.