Cisco Unified IP Phone Services Application Development Notes, Release 7.1(2)
HTTP Requests and Header Settings
Downloads: This chapterpdf (PDF - 134.0KB) The complete bookPDF (PDF - 2.89MB) | Feedback

HTTP Requests and Header Settings

Table Of Contents

HTTP Requests and Header Settings

HTTP Client Requests (HTTP GET)

HTTP Server Requests (HTTP POST)

HTTP Header Settings

HTTP Refresh Setting

MIME Type and Other HTTP Headers

Audio Clips

Content Expiration Header Setting

Set-Cookie Header Setting

HTTP Encoding Header Setting

HTTP Response Headers: Content-Type

Identifying the Capabilities of IP Phone Clients

x-CiscoIPPhoneModelName

x-CiscoIPPhoneDisplay

x-CiscoIPPhoneSDKVersion

Accept Header

Accessing IP Phone Information


HTTP Requests and Header Settings


Cisco Unified IP Phones use HTTP to communicate to external applications. The phone firmware includes both an HTTP client for making requests, and an HTTP server for receiving requests. This chapter describes the capabilities of the HTTP interface.

This chapter contains the following sections:

HTTP Client Requests (HTTP GET)

HTTP Server Requests (HTTP POST)

HTTP Header Settings

Identifying the Capabilities of IP Phone Clients

Accept Header

Accessing IP Phone Information

HTTP Client Requests (HTTP GET)

The following description designates how HTTP client requests are handled:

1. The Cisco Unified IP Phone HTTP client performs an HTTP GET for a specified URL.

2. The HTTP server processes request and returns an XML object or plain text.

3. The phone processes the supported HTTP headers.

4. The phone parses the XML object if ContentType is text/xml.

5. The phone presents data and options to the user, or in the case of a CiscoIPPhoneExecute object, begins executing the URIs.

HTTP Server Requests (HTTP POST)

The following description designates how an HTTP server request is made to the phone via an HTTP POST operation:

1. The server performs an HTTP POST in response to a case-sensitive URL of the phone with this format: http://x.x.x.x/CGI/Execute, where x.x.x.x represents the IP address of the destination Cisco Unified IP Phone.

The form that is posted should have a case-sensitive form field name called "XML" that contains the desired XML object. For any HTTP POST operation, the server must provide basic HTTP authentication information with the POST. The provided credentials must be of a user in the global directory with a device association with the target phone.

If the credentials are invalid, or the Authentication URL is not set properly in the Cisco Unified Communications Manager Administration, the phone will return a CiscoIPPhoneError with a value of 4 (Authentication Error) and processing will stop.

2. The phone processes the supported HTTP headers

3. The phone parses and validates the XML object

4. The phone presents data and options to the user, or in the case of a CiscoIPPhoneExecute object, begins executing the URIs.


Tip Any HTTP POST object is limited to 512 bytes in size. Larger objects (such as images) can only be delivered to the phone via HTTP GET. So, to push large objects to the phone, the server application must take an indirect approach. To do this, push an Execute object to the phone that contains an ExecuteItem pointing to the URL of the large object.



Note JTAPI also can push an XML object directly to an IP phone, with the added benefit of not requiring authentication (since the JTAPI connection itself is already authenticated). This option works particularly well for adding XML services interfaces to existing CTI applications (where the overhead of the CTI connection is already a requirement). Objects pushed via JTAPI are also limited to a maximum size of 512 bytes. See the Cisco Unified Communications Manager JTAPI Developer Guide for more information.


HTTP Header Settings

The following list provides definitions for HTTP header elements for Cisco Unified IP Phone Services:

"Refresh"—sets the refresh time (in seconds) and URL

If no time is set or it is zero, the refresh gets set to manual.

If no URL is set, the current URL gets used.

See the "HTTP Refresh Setting" section section.

ContentType —notifies the phone of the MIME type that was sent. See the "MIME Type and Other HTTP Headers" section section.

"Expires"—sets the Date/Time in GMT when the page is to expire.

Pages that have expired before being loaded do not get added to the URL stack in the phone. The phone does not cache content. See "Content Expiration Header Setting" section for more information.

"Set Cookie" - see "Set-Cookie Header Setting" section

"HTTP Encoding Header Setting" section

HTTP Refresh Setting

The HTTP headers that are sent with any page from an HTTP server can include a Refresh setting. This setting comprises two parameters: a time in seconds and a URL. These two parameters direct the recipient to wait the time given in the seconds parameter and then get the data to which the URL points.

The Cisco Unified IP Phone HTTP client properly supports this setting, which gives a great deal of power to service developers. It means that a new page can replace any XML object that displays after a fixed time.

Figure 5-1 shows an example of how to use the refresh setting. This sample page shows the user the current value of Cisco stock.

1. A splash screen that displays the Yahoo logo.

2. After a very short time, it displays the numeric Cisco stock parameters.

3. Finally, it shows a graph of Cisco intraday stock performance. The display then repeatedly cycles between the final two views.

Figure 5-1 Refresh Display Sample

Refreshing the display can occur without user intervention, because the display automatically cycles if a timer parameter is specified. On any given screen, however, the user can force an immediate reload by pressing the Update softkey. Also, if a timer parameter of 0 was sent in the header, the page never automatically reloads. In this case, the display will move to the next page only when the Update softkey is pressed. If no refresh URL is specified, the current page gets reloaded.

MIME Type and Other HTTP Headers

Although delivering pages with the proper MIME type and other formatting items is not difficult, it requires moderately in depth knowledge of your web server. The following code excerpt, written in JavaScript and used with Microsoft IIS and ASP, sets these values in a few lines:

<%@ Language=JavaScript %>
<% 
Response.AddHeader( "Refresh", 
                    "3; url=http://services.cisco.com/s/q.asp");
Response.ContentType = "text/xml";
//
// Additional page content here
//
%>

Usually, you can set the MIME type for pages in any web server by simply performing an association to the .xml file extension. Your web server documentation should explain how to accomplish this. This action allows you to serve static pages without the need for writing script.

If you want to deliver dynamic content by using the other supported HTTP headers, you will need to understand how to generate the HTTP headers by using the desired programming language and have common gateway interface (CGI) or script access on the target web server.

Audio Clips

You can serve audio clips to the phone from a web server by using the "audio/basic" MIME type setting. When this MIME type is used, the body of the response should contain raw audio data in the same format that is used for custom Cisco Unified IP Phone rings. Refer to the chapter on "Custom Phone Rings" in the Cisco Unified Communications Manager System Guide (also available in the online help).


Note The audio file should not be longer than five seconds.


Use the following ASP sample script to set the MIME type and to serve the file that is specified in the #include command:


<%@ Language=JavaScript%>
<%
Response.ContentType = "audio/basic"; 
%><!--#include file="filename.raw" --><% Response.End();%>

Using script to generate the MIME header when playing a sound provides an advantage because you may also include a refresh header to take the phone to a subsequent URL. Usually, you can set the MIME type for pages in any web server by simply performing an association to the .xml or .raw file extension. Your web server documentation should explain how to accomplish this. This action allows you to serve static pages without the need for writing script.

Content Expiration Header Setting

The expiration header can control which URLs are added to the phone URL history. This behavior differs slightly from traditional web browsers but is implemented to perform the same function. Disable the back button functionality to avoid calling a URL twice.

This functionality allows you to make the content of any page that is sent to the phone expire. When a user presses the Exit softkey, the user goes back to the last URL that did not expire when it was loaded. This differs from traditional browsers by not considering the current freshness of the data but the freshness of the data when the URL was requested. This requires you to have a page expire when it is first loaded and to not set a time and date in the future.

The following example shows how to have content on IIS expire by using Active Server Page (ASP):

<%@ Language=JavaScript %>
<%
   Response.ContentType = "text/xml";
   Response.Expires = -1;
%>

The "Expires" property specifies the number of minutes to wait for the content to expire. Setting this value to -1 subtracts 1 minute from the request time and returns a date and time that have already passed.

Set-Cookie Header Setting

A "cookie" is a term for a mechanism that the Web server uses to give the client a piece of data and have the client return the data with each request. The two traditional uses for cookies are:

For Web sites to store a unique identifier and/or other information on the client's file system. The information is available to the Web server on subsequent visits.

To track a unique identifier for state management. The client returns the cookie with each request and the server uses this identifier to index information about the current session. The identifier is commonly referred to as a session ID. Most Web servers have a built-in session management layer that uses this second type of cookie, which is commonly referred to as a session cookie.

The following example shows the Set-Cookie header that is returned to the browser when a request method is used:

Set-Cookie: ASPSESSIONIDGQGQGRLS=OCPNMLFDBJIPNIOOKFNFMOAL; path=/

The Cisco Unified IP Phone can receive and use a total of four cookies per host per session and can store information for up to eight sessions at once. Each cookie can be up to 255 bytes in size. These cookies are available until the server terminates the session or the client session has been idle for more than 30 minutes. On the latest generation phones which are capable of running multiple applications concurrently (Cisco Unified IP Phones 7970G, 7971G, 7961G, 7941G, 7911G), the session state is also cleared whenever the application window closes. This behavior is consistent with PC-based browsers and provides better security since anyone attempting to reopen a secure application would be forced to authenticate. If the client is connecting to a new server and all session resources are in use, the client clears and reuses the session with the longest inactivity time.

When using ASP on IIS the default server configuration automatically generates a session cookie and sends it to the client using the Set-Cookie header. This enables you to utilize the Session object from within ASP to store and retrieve data spanning multiple requests for the life of the session. When using JSP on Tomcat, the default configuration generates and issues a session cookie.

HTTP Encoding Header Setting

The encoding header controls language and character settings related to localization.

Accept-Language

Cisco Unified IP Phones populate the Accept-Language HTTP request header in compliance with the HTTP specification.

For example, the Accept-Language value advertised by a phone configured for the English_United_States user locale would look like:

Accept-Language: en-US

Accept-Charset

As of this release, the phones are capable of handling UTF-8 encoding and, depending on phone model, some degree of Unicode support.

The phone models (such as the 7940, 7960, 7905 and 7912) can handle UTF-8 encoding, but will only recognize characters which can be represented by the default encoding of the phone's current user locale. For example, if the phone is currently configured to use the English_United_States locale, then it will only be able to display UTF-8 characters which map to the ISO-8859-1 character set.

The phone models (such as the 7970, 7971, 7941, 7961, and 7911) provide UTF-8 and true Unicode support. These phones provide support for more multi-byte character sets and user locales like Japanese and Chinese.

In addition to the character set for the currently configured user locale, the new phone models will also support ISO-8859-1 characters in their font files.

All phones will advertise their supported encodings using the standard HTTP Accept-Charset header. Per HTTP standard, q-values are used to specify preferred encodings. The older phone models, with more limited UTF-8 support, will specify a lower q-value for UTF-8 than the default user locale encoding.

For example, an older phone model configured with the English_United_States user locale would include an Accept-Charset header similar to the following:

Accept-Charset: iso-8859-1, utf-8;q=0.8

A newer phone model with Unicode support would advertise an Accept-Charset similar to the following:

Accept-Charset: utf-8,iso-8859-1;q=0.8

HTTP Response Headers: Content-Type

Because the phones are capable of supporting multiple character encodings, HTTP responses returned to the phones should include the 'charset' parameter on the HTTP Content-Type header. Examples of responses including the "charset" parament are shown below:

Content-Type: text/xml; charset=ISO-8859-1

Content-Type: text/xml; charset=UTF-8

Content-Type: text/plain; charset=Shift_JIS

HTTP standards state that if the encoding is not explicitly specified, ISO-8859-1 is the default.Cisco Unified IP Phones are typically compatible with this spec, but not fully compliant.

If 'charset' is not specified, the phones will use the default encoding for the currently configured user locale. So to avoid possible problems where the phone's default encoding may NOT be ISO-8859-1, the web server should explicitly set the Content-Type charset (which must match one of the Accept-Charset values specified by the phone).

Identifying the Capabilities of IP Phone Clients

XML services are supported on many Cisco Unified IP Phones, so web application servers must identify the capabilities of the requesting IP phone to optimize the content returned to the phone. For example, if the requesting phone is a Cisco Unified IP Phone 7960, which cannot support color PNG images, the application server must be able to identify this and return a gray scale CIP image instead.

The IP phone client request to send the relevant information from the IP phone to the web server application includes three (3) HTTP headers:

x-CiscoIPPhoneModelName

x-CiscoIPPhoneDisplay

x-CiscoIPPhoneSDKVersion

x-CiscoIPPhoneModelName

This Cisco-proprietary header contains the Cisco manufacturing Model Name of the device, which can typically be found by going to Settings > Model Information, but varies between different models. Some examples of manufacturing Model Names are CP-7960, CP-7960G, CP-7940G, CP-7905G, and CP-7970G.

x-CiscoIPPhoneDisplay

This Cisco-proprietary header contains the display capabilities of the requesting device with the following four parameters (listed in the order in which they appear):

Width (in pixels)

Height (in pixels)

Color depth (in bits)

A single character indicating whether the display is color (''C'') or gray scale (''G'')

These parameters get separated by commas as shown in the following example of a Cisco Unified IP Phone 7970 header:

x-CiscoIPPhoneDisplay: 298, 168, 12, C


Note The pixel resolutions advertised by the device define the area of the display accessible by the phone services; not the actual resolution of the display.


x-CiscoIPPhoneSDKVersion

This Cisco-proprietary header contains the version of the IP Phone Services SDK that the requesting phone supports. The HTTP header does not specify which URIs are supported. Therefore, you must check the "Supported URIs" matrix in the IP Phone Services SDK to determine which URIs are supported based on the Phone Model Name and supported SDK version.

See Table 4-1 table to find which IP phone models support the URIs documented in this SDK.


Note Beginning with the IP Phone Services SDK 3.3(3), the SDK version number matches the minimum Cisco Unified Communications Manager software that is required to support it. For example, SDK version 3.3(4) gets supported only on Cisco Communications Manager version 3.3(4) or later.


Accept Header

The Accept header represents a standard HTTP header that is used to inform web servers about the content-handling capabilities of the client.

Cisco Unified IP Phones include proprietary content-types to indicate which XML objects are supported. These proprietary content-types all begin with x-CiscoIPPhone, to indicate Cisco Unified IP Phone XML objects, followed by a slash "/", followed by either a specific XML object or a "*" to indicate all objects.

For example, x-CiscoIPPhone/* indicates that all XML objects defined in the specified version of the SDK are supported, and x-CiscoIPPhone/Menu specifies that the <CiscoIPPhoneMenu> object gets supported.

As the example illustrates, the name of the XML object can be derived directly from the content-type by appending the sub-type (the part after the slash) onto "CiscoIPPhone." The content-type can also include an optional version to indicate support for a particular SDK version of that object. If a version is not specified, then the x-CiscoIPPhoneSDKVersion is implied. The syntax of the version number may vary, but, in general, will be as follows:

<major version>.<minor version>.<maintenance version>

Here are some examples of typical content-types:

x-CiscoIPPhone/*;version=3.3.3

x-CiscoIPPhone/Text

x-CiscoIPPhone/Menu;version=3.3.4

Accessing IP Phone Information

Cisco Unified IP Phones have an embedded web server to provide a programming interface for external applications and a debugging and management interface for system administrators.

You can access the administrative pages using a standard web browser and pointing to the IP address of the phone with: /http://<phoneIP>/, where phoneIP is the IP address of the specific phone.

These device information pages are available in either HTML format, for manual debugging purposes, or in XML format for automation purposes. Table 5-1 lists the available URLs and their purpose.

Table 5-1 Device Information URLs 

HTML URL
XML URL
Description

/DeviceInformation

/DeviceInformationX

General device information

/NetworkConfiguration

/NetworkConfigurationX

Network configuration information

/EthernetInformation

/EthernetInformationX

Ethernet counters

/PortInformation?n

/PortInformationX?n

Detailed port information, where n is a model-specific ethernet port identifier, typically in the range 1- 3.

/DeviceLog?n

/DeviceLogX?n

Device logging, debug, and error messages, where n is a model-specific log number, typically in the range 0 - 2.

/StreamingStatistics?n

/StreamingStatisticsX?n

Current RTP streaming stats, where 'n' is model-specific RTP stream identifier, typically in the range 1-3.

/CGI/Execute1

The target URL of a phone push (HTTP POST) request.

/CGI/Screenshot1

Returns an exact snapshot of the current phone display. The size and format of the image returned is model-specific.

1 Password-protected CGI script