UAProf

UAProf / User Agent Profile Reference

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

UAProf / User Agent Profile was defined by the Open Mobile Alliance (formerly the WAP Forum) for detecting user agent types and device capabilities. The User Agent Profile schema has specified a set of base attribute names so that different mobile device manufacturers can use the same set of base attribute names to describe the features and capabilities of mobile devices. For example, the screen size of a cell phone is always found in the ScreenSize attribute of the HardwarePlatform component no matter who the manufacturer is. In this reference, you can find the base attribute names, their meanings and some examples.

Table of Contents

User Agent Profile / UAProf Reference -- HardwarePlatform Component
The HardwarePlatform component of User Agent Profile / UAProf provides information about the hardware capabilities of the mobile device. For example, color capability, model name of mobile device, text input capability, screen size and sound capability.

 

User Agent Profile / UAProf Reference -- SoftwarePlatform Component
The SoftwarePlatform component of User Agent Profile / UAProf provides information about the software characteristics of the mobile device. For example, audio and video encoders supported, character sets accepted, Java capability, acceptable content types / MIME types and operating system name and version.

 

User Agent Profile / UAProf Reference -- NetworkCharacteristics Component
The NetworkCharacteristics component of User Agent Profile / UAProf provides information about the capabilities of the mobile device for network connection. For example, bearers supported (CSD, GPRS, SMS, EDGE, etc) and encryption methods supported (WTLS, SSL, TLS, etc).

 

User Agent Profile / UAProf Reference -- BrowserUA Component
The BrowserUA component of User Agent Profile / UAProf provides information about the browser of the mobile device. For example, mobile browser name and version, HTML version supported, XHTML version supported and JavaScript capability.

 

User Agent Profile / UAProf Reference -- WapCharacteristics Component
The WapCharacteristics component of User Agent Profile / UAProf provides information about the WAP features supported by the mobile device. For example, DRM (digital rights management) capability, maximum WML deck size, WAP version supported and WMLScript libraries supported.

 

User Agent Profile / UAProf Reference -- PushCharacteristics Component
The PushCharacteristics component of User Agent Profile / UAProf provides information about the WAP Push capabilities of the mobile device. For example, character encodings supported, character sets supported, content types / MIME types supported and maximum WAP Push message size.

 

User Agent Profile / UAProf Reference -- MmsCharacteristics Component
The MmsCharacteristics component of User Agent Profile / UAProf provides information about the MMS (Multimedia Messaging Service) capabilities of the mobile device. For example, maximum MMS message size supported, maximum image resolution supported and character sets supported.

 

 

 

Disclaimer Notice

We have made an effort to ensure the accuracy of information available on this web site. However, we do not warrant the correctness of these materials and assume no responsibility for errors or omissions in these materials. Please refer to Terms of Use for the details before using this web site.

 

User Agent Detection and Client Device Capabilities Detection

Introduction

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

The number of client devices supported by an application is a major factor that determines whether the application will be a success or failure. Building an application that supports lots of user agents is not so straightforward because:

  • There are many different types of wireless devices these days. For example, there are cell phones, PDAs (personal digital assistants), smart watches, etc. Each type of wireless device has very different features and capabilities.

  • Even for the same type of wireless device, there are many different models and they have very different features and capabilities. For example, some cell phone models have a large screen that supports a high resolution; some have a color screen; some support both XHTML MP and WML while some others only support WML; some support Java applications while some others do not.

  • If your application is required to work on both wireless devices and personal computers, then you have to further take personal computers into consideration. Computers and wireless devices have very different features and capabilities.

In this tutorial, we will describe two common ways for detecting user agent types and device capabilities. The first way is to use the information in some traditional HTTP headers such as Accept , User-Agent , Accept-Charset and Accept-Language . The second way is to use UAProf (User Agent Profile), the standard way defined by the Open Mobile Alliance (formerly the WAP Forum) for detecting user agent types and device capabilities.

The advantage of UAProf is that it provides more detail information about the user agent and the wireless device than traditional HTTP headers. The drawback of UAProf is that old wireless device models do not support it.

 

Headers in HTTP Requests

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

Information about the type and capabilities of a client device such as a cell phone can be found in the headers of HTTP requests received at the server-side. Here are some of the headers that are useful for detecting user agent types, features and capabilities of client devices:

  • The Accept header

  • The User-Agent header

  • The Accept-Charset header

  • The Accept-Language header

  • The x-wap-profile header and the Profile header. They contain the URL to a UAProf document.

The Accept Header -- Find the MIME Media Types that will be Accepted by a User Agent

The Accept header contains a list of MIME media types that will be accepted by the user agent. We can use the Accept header to find out the file types that can be handled by the user agent. The Accept header contains something like this:

 

application/vnd.wap.wmlscriptc, text/vnd.wap.wml, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/html, multipart/mixed, */*

 

The above Accept header is generated by the Nokia 6230i cell phone emulator. It states that the Nokia 6230i cell phone can handle WMLScript scripts, WML documents, XHTML MP documents, HTML documents, etc. "*/*" means all MIME media types. Similarly, if you see "application/*", it means all MIME types that begin with "application/" are acceptable. If "*" is used in the Accept header, the information we can get is more limited. For example, some cell phones include the MIME type "text/vnd.sun.j2me.app-descriptor" in the Accept header, which tells us the cell phone is capable of running J2ME programs. However, if what we can find is "*/*", we are not sure whether the cell phone can ready handle J2ME programs or it can just accept the file and save it locally. In such cases, you may want to use other detection methods such as UAProf.

Now let's say the WML or XHTML MP document downloaded from a WAP server contains an inline image <img src="image.gif" ... />. The Nokia 6230i cell phone will send another HTTP request to the WAP server to get the image file. This time the Accept header will contain something like:

 

image/vnd.wap.wbmp, image/gif, image/jpg, image/jpeg, image/png, image/bmp, image/x-bmp

 

The above Accept header states that the Nokia 6230i cell phone accepts image formats like WBMP, GIF, JPEG, PNG, BMP, etc. From this information, we know that Nokia 6230i is a cell phone model that has a color screen since GIF, JPEG, PNG and BMP are image formats that support colors.

To learn further details about the Accept header, please refer to the HTTP/1.1 specification at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 .

Common MIME Types List

The following table lists some common MIME types that you may find in the Accept header generated by a wireless device such as a cell phone:

 

File Type

MIME Media Type

Audio 3GPP files (.3gp)

audio/3gpp

Audio AMR files (.amr)

audio/amr

Audio AMR (wideband) files (.awb)

audio/amr-wb

Audio MIDI files (.mid or .midi)

audio/midi

Audio MP3 files (.mp3)

audio/mpeg

Audio MP4 files (.mp4)

audio/mp4

Audio WAV files (.wav)

audio/wav

audio/x-wav

HTML files (.html or .htm)

text/html

Image BMP files (.bmp)

image/bmp

image/x-bmp

Image GIF files (.gif)

image/gif

Image JPEG files (.jpg or .jpeg)

image/jpeg

Image PNG files (.png)

image/png

Image TIFF files (.tif or .tiff)

image/tiff

Image WBMP (Wireless BMP) files (.wbmp)

image/vnd.wap.wbmp

Java application JAR files (.jar)

application/java

application/java-archive

application/x-java-archive

Java application JAD files (.jad)

text/vnd.sun.j2me.app-descriptor

Plain text files (.txt)

text/plain

Symbian application SIS files (.sis)

application/vnd.symbian.install

Video 3GPP files (.3gp)

video/3gpp

Video MP4 files (.mp4)

video/mp4

WML files (compiled) (.wmlc)

application/vnd.wap.wmlc

WML files (plain text) (.wml)

text/vnd.wap.wml

WMLScript files (compiled) (.wmlsc)

application/vnd.wap.wmlscriptc

WMLScript files (plain text) (.wmls)

text/vnd.wap.wmlscript

XHTML MP files (.xhtml, .html or .htm)

application/vnd.wap.xhtml+xml

application/xhtml+xml

text/html

 

The User-Agent Header -- Identify a User Agent and Client Device

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

The User-Agent header contains a line of text that can be used to identify a user agent and client device. Most of the time, we can find the device model and manufacturer from the User-Agent header. It may also contain information such as the client device's OS version, browser version, Java capabilities, etc.

Some example User-Agent headers are provided below.

 

The User-Agent header of the Nokia 6230i cell phone:

Nokia6230i/2.0 (03.25) Profile/MIDP-2.0 Configuration/CLDC-1.1

 

The User-Agent header of the Nokia 6600 cell phone:

Nokia6600/1.0 (4.03.24) SymbianOS/6.1 Series60/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.0

 

The User-Agent header of the Sony Ericsson T610 cell phone:

SonyEricssonT610/R501 Profile/MIDP-1.0 Configuration/CLDC-1.0

 

The User-Agent header of the Sony Ericsson K700i cell phone:

SonyEricssonK700i/R2AG SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1

 

The User-Agent header of Openwave Mobile Browser 6.2.2:

OPWV-SDK/62 UP.Browser/6.2.2.1.208 (GUI) MMP/2.0

 

One big problem of the User-Agent header is that its format is different for different manufacturers of mobile devices / cell phones. There are also variations among mobile devices / cell phones of the same manufacturer. Future device models might include a new string token in the User-Agent header or even use a completely new User-Agent header format.

Because of such problems, even though the User-Agent header may contain information about a mobile device's OS version, browser version, Java capabilities, etc , usually we do not use it for device capability detection. To detect the features and capabilities of a mobile device, the UAProf way is preferred, which will be discussed later in this tutorial.

In general, the User-Agent header is useful in the following situations:

  • When we need to identify a specific mobile device model. For example, the User-Agent header can help us determine whether a mobile device is a Nokia 6230i cell phone.

  • When we need to differentiate mobile devices or user agents made by different companies. For example, the User-Agent header can help us determine whether a cell phone is made by Nokia or Sony Ericsson.

  • When we need to determine whether a user agent is a web browser on a personal computer or a microbrowser on a mobile device.

To Identify a Specific Mobile Device Model with the User-Agent Header

In general, to identify a specific mobile device model, check whether the mobile device model name appears in the User-Agent header. For example, if the text "Nokia6230i" exists in the User-Agent header, we know that the mobile device is a Nokia 6230i cell phone; if the text "SonyEricssonK700i" exists in the User-Agent header, we know that the mobile device is a Sony Ericsson K700i cell phone.

As said earlier, each mobile device manufacturer has its own User-Agent header format. Thus, the keyword to use to identify a specific mobile device model is different for different manufacturers. You may need to check the website of the mobile device manufacturer to find its User-Agent header format or consider to use other detection methods such as UAProf. (With UAProf, the mobile device model and manufacturer name are available in the Model attribute and the Vendor attribute of the HardwarePlatform component respectively.)

To Differentiate Mobile Devices or User Agents Made by Different Companies with the User-Agent Header

In general, the User-Agent header contains information that can help us differentiate mobile devices or user agents made by different companies. Here are some examples: (Note: the keywords below are in lowercase but they may not be so in the actual User-Agent header)

 

  • The word "nokia" can be found in the User-Agent header of Nokia's cell phones.

  • The word "motorola" or "mot-" can be found in the User-Agent header of Motorola's cell phones.

  • The word " samsung" or "sec-" can be found in the User-Agent header of Samsung's cell phones.

  • The word "lg-" can be found in the User-Agent header of LG's cell phones.

  • The word "sonyericsson" can be found in the User-Agent header of Sony Ericsson's cell phones.

  • The word "sie-" can be found in the User-Agent header of Siemens' cell phones.

  • The word "up.b" or "up/" can be found in the User-Agent header of cell phones that uses the Openwave Mobile Browser. The Openwave Mobile Browser can be found in many cell phone models made by a variety of manufacturers such as Motorola, Samsung, LG, Siemens, etc.

 

Note that UAProf is a more elegant way for differentiating the manufacturers of mobile devices / user agents. (With UAProf, the name of the manufacturer is available in the Vendor attribute of the HardwarePlatform component.)

To Determine Whether a User Agent is a Web Browser on a Personal Computer or a Microbrowser on a Mobile Device with the User-Agent Header

Another common use of the User-Agent header is to determine whether the user agent is a web browser on a personal computer or a microbrowser on a mobile device. Below shows the User-Agent header of Microsoft Internet Explorer 6 and Mozilla Firefox 1.0.7 running on Windows 2000:

 

Microsoft Internet Explorer 6:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

 

Mozilla Firefox 1.0.7:

Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7

 

If you compare the User-Agent headers of IE and Firefox with those of microbrowsers that were shown earlier, you will find that the User-Agent header of IE and Firefox contains the word "Mozilla" while those of microbrowsers do not. This can be served as a simple rule to determine whether a user agent is a web browser on a personal computer or a microbrowser on a mobile device.

Note that the above rule does not work in all cases. The User-Agent header of s ome microbrowsers also contains the word "Mozilla". For example, some Nokia 6630 cell phones use a "Mozilla compatible" User-Agent header. The reason is that Nokia 6630 is a web-compatible cell phone and can accept HTML content, but some websites that are designed for desktops will deny access to Nokia 6630 if the "Mozilla compatible" User-Agent header is not present.

 

"Mozilla compatible" User-Agent header of the Nokia 6630 cell phone:

Mozilla/4.0 (compatible; MSIE 5.0; Series60/2.8 Nokia6630/4.06.0 Profile/MIDP-2.0 Configuration/CLDC-1.1)

 

To increase accuracy, you can further check the OS name and browser name in the User-Agent header. For example, if you find the word "Mozilla" and the OS name "Windows NT" in the User-Agent string, it is almost certain that the user agent is a web browser on a computer but not on a mobile device; if you find the word "Mozilla" and the browser name "Firefox" , it is certain that the user agent is a Firefox browser running on a computer since Firefox does not have a mobile device version (at the time of this writing).

The Accept-Charset Header -- Find Character Sets that are Supported by a User Agent

The Accept-Charset header specifies the character sets that are supported by the user agent. This HTTP header is useful to non-English sites. Some example Accept-Charset headers are provided below:

 

Nokia 6230i:

ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6

 

Openwave Mobile Browser 6.2.2 (the Accept-Charset header value can be changed in the Options dialog of the emulator):

iso-8859-1

 

In the Accept-Charset header of Nokia 6230i, UTF-8 and ISO-10646-UCS-2 are assigned a quality value of 0.8 and 0.6 respectively. It means UTF-8 has a higher preference than ISO-10646-UCS-2. The default quality value is 1. So, ISO-8859-1 and US-ASCII have a quality value of 1.

If the character set used by your WAP or web site cannot be found in the Accept-Charset header, you should notify the user of the problem by sending a page that contains an error message to the mobile device. Of course the error message should be encoded in a character set that is acceptable by the user agent.

To learn further details about the Accept-Charset header, please refer to the HTTP/1.1 specification at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2 .

The Accept-Language Header -- Find the Language Preference

The Accept-Language header contains information about the language preference of a user. This HTTP header is useful to multilingual sites for deciding the best language to serve to the client. Some example Accept-Language headers are provided below:

 

Nokia 6230i (the Accept-Language header value can be changed in the Preferences dialog of the emulator):

en

 

Nokia Mobile Browser 4.0:

en, fi

 

Openwave Mobile Browser 6.2.2 (the Accept-Language header value can be changed in the Options dialog of the emulator):

en

 

In the above examples, "en" means English and "fi" means Finnish. The language code can be followed by a hyphen and then a two-character country code. For example, "en-us" means American English and "en-gb" means British English. The full lists of language code and country code are available at http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt and http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html .

Languages in the Accept-Language header may be associated with a quality value that specifies the order of preference. For example:

 

zh, en-us; q=0.8, en; q=0.6

 

American English (en-us) is assigned a quality value of 0.8 while English (en) is assigned a quality value of 0.6. Since the default quality value is 1, Chinese (zh) is assigned a quality value of 1. The whole line means Chinese is preferred. If a Chinese version is not available, American English is preferred. If there are no Chinese and American English versions, other forms of English is preferred.

To learn further details about the Accept-Language header, please refer to the HTTP/1.1 specification at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 .

The x-wap-profile Header and the Profile Header -- Find the UAProf Document of a Mobile Device

UAProf (User agent profile) is an XML document that contains information about the features and capabilities of a mobile device. Very often the URL that points to the UAProf document of a mobile device can either be found in the x-wap-profile header or the Profile header, but in some cases it is located in other HTTP headers. Some example x-wap-profile headers and Profile headers are provided below:

 

Nokia 6230i:

"http://nds1.nds.nokia.com/uaprof/N6230ir200.xml"

 

Nokia 6230:

"http://nds1.nds.nokia.com/uaprof/N6230r200.xml"

 

Openwave Mobile Browser 6.2.2:

"http://developer.openwave.com/uaprof/OPWVSDK62.xml"

 

We will provide more details about UAProf in the " Using UAProf (User Agent Profile) to Detect User Agent Types and Device Capabilities " section of this tutorial.

How to Read the Value of an HTTP Header

In the above sections, we have gone through several HTTP headers that are useful for user agent detection and device capabilities detection. Now one essential question remains: how to read the value of an HTTP header?

Reading the value of an HTTP header is not difficult. Just use a server-side scripting technology to write a few lines of code. We will demonstrate how to read the value of an HTTP header using ASP, Java Servlet / JSP, Perl and PHP below.

Retrieving HTTP Headers with ASP

In ASP, you can use the ServerVariables collection of the Request object to retrieve the value of HTTP headers. You can choose either VBScript or JScript (JavaScript implemented by Microsoft) as the scripting language. If you use VBScript, the code for reading HTTP headers should be like this:

 

' Declaring variables
Dim accept
Dim user_agent
Dim accept_charset
Dim accept_language
Dim x_wap_profile
Dim profile

accept = Request.ServerVariables("HTTP_ACCEPT")
user_agent = Request.ServerVariables("HTTP_USER_AGENT")
accept_charset = Request.ServerVariables("HTTP_ACCEPT_CHARSET")
accept_language = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
x_wap_profile = Request.ServerVariables("HTTP_X_WAP_PROFILE")
profile = Request.ServerVariables("HTTP_PROFILE")

 

As you can see above, to retrieve the value of an HTTP header in ASP , we use Request.ServerVariables("HTTP_x") , where x is the HTTP header name with all the "-" characters replaced with the "_" character. ASP has other pre-defined server environment variables that can be placed inside the parentheses of ServerVariables() but we are not going to discuss about them since they are not useful to us here.

If you use JScript, the code for reading HTTP headers should look like this:

 

var accept = Request.ServerVariables("HTTP_ACCEPT");
var user_agent = Request.ServerVariables("HTTP_USER_AGENT");
var accept_charset = Request.ServerVariables("HTTP_ACCEPT_CHARSET");
var accept_language = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE");
var x_wap_profile = Request.ServerVariables("HTTP_X_WAP_PROFILE");
var profile = Request.ServerVariables("HTTP_PROFILE");

Retrieving HTTP Headers with Java Servlet / JSP

In Java Servlet or JSP, you can use the getHeader() method of the javax.servlet.http.HttpServletRequest object to retrieve the value of HTTP headers. Here is the code for reading HTTP headers:

 

String accept = request.getHeader("accept");
String user_agent = request.getHeader("user-agent");
String accept_charset = request.getHeader("accept-charset");
String accept_language = request.getHeader("accept-language");
String x_wap_profile = request.getHeader("x-wap-profile");
String profile = request.getHeader("profile");

 

As you can see, to retrieve the value of an HTTP header whose name is x in Java Servlet or JSP , we use request.getHeader("x") , where request is an instance of the javax.servlet.http.HttpServletRequest class .

Retrieving HTTP Headers with Perl

In Perl, the values of HTTP headers are stored in the %ENV hash. Here is the code for retrieving HTTP headers:

 

$accept = $ENV{"HTTP_ACCEPT"};
$user_agent = $ENV{"HTTP_USER_AGENT"};
$accept_charset = $ENV{"HTTP_ACCEPT_CHARSET"};
$accept_language = $ENV{"HTTP_ACCEPT_LANGUAGE"};
$x_wap_profile = $ENV{"HTTP_X_WAP_PROFILE"};
$profile = $ENV{"HTTP_PROFILE"};

 

As you can see above, to retrieve the value of an HTTP header in Perl , we use $ENV{"HTTP_x"} , where x is the HTTP header name with all the "-" characters replaced with the "_" character. Perl has other pre-defined values that can be placed inside the braces of $ENV{} but we are not going to discuss about them since they are not useful to us here.

Retrieving HTTP Headers with PHP

In PHP, the value of HTTP headers are stored in the $_SERVER array. Here is the code for retrieving HTTP headers:

 

$accept = $_SERVER["HTTP_ACCEPT"];
$user_agent = $_SERVER["HTTP_USER_AGENT"];
$accept_charset = $_SERVER["HTTP_ACCEPT_CHARSET"];
$accept_language = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
$x_wap_profile = $_SERVER["HTTP_X_WAP_PROFILE"];
$profile = $_SERVER["HTTP_PROFILE"];

 

As you can see above, to retrieve the value of an HTTP header in PHP , we use $_SERVER["HTTP_x"] , where x is the HTTP header name with all the "-" characters replaced with the "_" character. PHP has other pre-defined values that can be placed inside the square brackets of $_SERVER[] but we are not going to discuss about them since they are not useful to us here.

Using UAProf (User Agent Profile) to Detect User Agent Types and Device Capabilities

Introduction

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

UAProf (User agent profile) is an XML document that contains information about the user agent type and device capabilities. It is a standard defined and maintained by the Open Mobile Alliance (formerly the WAP Forum).

UAProf was created according to the CC/PP (Composite Capabilities/Preferences Profiles) framework with RDF (Resource Description Framework) as the schema. Both CC/PP and RDF were defined by the W3C (World Wide Web Consortium).

User agent profiles are stored in a server called the profile repository. Very often a profile repository is maintained by a mobile device manufacturer. For example, the user agent profiles describing the capabilities of Nokia cell phones are stored in a profile repository maintained by Nokia.

The URL that points to the user agent profile of a mobile device can be found in the headers of requests sent by the mobile device. Very often the URL is located in the x-wap-profile header or the Profile header. For example, the value of the x-wap-profile header generated by a Nokia 6230i cell phone is:

 

"http://nds1.nds.nokia.com/uaprof/N6230ir200.xml"

 

A user agent profile contains a number of components and each component has a number of attributes. For example, if you download and open Nokia 6230i's user agent profile, you will find the ScreenSize attribute under the HardwarePlatform component, like this:

 

...
<prf:component>
  <rdf:Description rdf:ID="HardwarePlatform">
    <rdf:type rdf:resource= "http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20021212#HardwarePlatform"/>
...
    <prf:ScreenSize>208x208</prf:ScreenSize>
...
  </rdf:Description>
</prf:component>
...

From the above user agent profile, we know that Nokia 6230i cell phones have a screen size of 208 pixels x 208 pixels.

The latest approved UAProf specification is WAP-248-UAProf-20011020-a , which is part of WAP 2.0. The newest version is OMA-UAProf-V2_0_20030520-C1 , which is still in the candidate phase.

Where to Find the URL of the UAProf Document of a Mobile Device

As mentioned earlier, the URL of the UAProf document of a mobile device can very often be found in the HTTP headers x-wap-profile or Profile . For example, if you look inside the HTTP requests sent by Nokia 6230i, you will find the following line:

 

x-wap-profile: "http://nds1.nds.nokia.com/uaprof/N6230ir200.xml"

 

If you cannot find the x-wap-profile header and the Profile header in an HTTP request, you may find the URL of the UAProf document by following the steps below:

1. Check if there are any Opt headers in the HTTP request. If yes, read the value of the Opt header that contains the URL "http://www.w3.org/1999/06/24-CCPPexchange" . The Opt header should contain something like this:

 

"http://www.w3.org/1999/06/24-CCPPexchange" ; ns=80

 

2. Extract the namespace number in the Opt header. In the above example, the namespace number is 80.

3. The URL of the UAProf document should be found in the NAMESPACE-Profile header, where NAMESPACE is the namespace number you found in the Opt header. For example:

 

80-Profile: " http://wap.sonyericsson.com/UAprof/T68R502.xml"

 

Note that not all mobile devices support UAProf and so you may not be able to find the URL of the UAProf document in HTTP headers. If the mobile device does not support UAProf, you can still find out certain information about the user agent using traditional HTTP headers such as Accept , Accept-Charset , Accept-Language and User-Agent .

UAProf Profile Resolution

Now you know how to find the URL of a UAProf profile, the next step is to download it and retrieve some attribute values from it. Retrieving a UAProf attribute value is not as simple as retrieving the value of an HTTP header like Accept or User-Agent . The reason is that UAProf is a complex specification that has taken many things into consideration. This makes UAProf powerful but also makes it contains a lot of rules. For example:

  • The UAProf specification allows more than one UAProf profile for a mobile device, which means you may find more than one URL in the x-wap-profile header.

  • The UAProf profiles may contain a default description block, which is used to specify default values to attributes. The default values may be specified in the document locally or in an external profile.

  • Two headers, x-wap-profile-diff and Profile-diff , can be used to specify changes to the original user agent profiles.

To find the final value of an attribute, we have to perform a process called profile resolution:

  • Read the default attribute values.

  • Read the attribute values specified in the UAProf profiles.

  • Read the changes specified in the x-wap-profile-diff headers or the Profile-diff headers.

  • Merge all these values by following a certain order and a set of rules.

When a default value merges a non-default value, the default value is always overriden by the non-default value. When a non-default value merges another non-default value, the UAProf parser follows the resolution rule of the attribute. The UAProf specification has defined three resolution rules (Locked , Override and Append ) that are used to tell the UAProf parser how to merge non-default values. Every attribute are associated with one of the resolution rules. The meanings of the three resolution rules are provided in the table below:

 

Resolution rule

Meaning

Locked

The attribute's final value is the first non-default value.

For example, the resolution rule of the ScreenSize attribute is Locked .

Override

The attribute's final value is the last non-default value.

For example, the resolution rule of the ColorCapable attribute is Override .

Append

The attribute's final value is the list of all non-default values.

For example, the resolution rule of the CcppAccept attribute is Append . (The CcppAccept attribute tells us the MIME media types acceptable by a mobile device.)

Let's say the first non-default occurrence of the CcppAccept attribute contains the items:

image/bmp
image/gif

The second non-default occurrence contains the items:

image/jpeg
image/png

After profile resolution, the CcppAccept attribute contains the items:

image/bmp
image/gif
image/jpeg
image/png

 

For more details about profile resolution, please refer to the UAProf specification.

Free Library / Tool for Retrieving UAProf Attribute Values

As you can see above, writing a UAProf parser to retrieve the values of attributes according to the UAProf specification requires a lot of work. Fortunately there is an open source library called DELI that can be used to query UAProf or CC/PP profiles in Java Servlets. It can be downloaded free of charge from the website http://delicon.sourceforge.net/ .

A Simple Way for Retrieving UAProf Attribute Values

As mentioned earlier, determining the final value of an attribute involves a lot of steps according to the UAProf specification. However, in real life, mobile device manufacturers and mobile operators keep things simple. In most situations:

  • There is only one UAProf profile for a mobile device. So, you will not find more than one URL in HTTP headers such as x-wap-profile , Profile , etc.

  • The UAProf profile of a mobile device does not specify any default description blocks.

  • No x-wap-profile-diff or Profile-diff headers are used to specify additional changes to the UAProf profile.

Hence, to get the final value of an attribute, no more profile merging is necessary. All you need to do is to obtain the URL of the user agent profile, download the user agent profile and then retrieve the attribute values you needed from the document using any method you like, such as simple text matching and XML parsing.

The advantage of using this way is that it is very simple and straightforward and it works most of the time. The disadvantage is that the attribute values retrieved may be incorrect if the above three points are not true.

UAProf Components and Attributes

The UAProf specification has defined a number of base components and attribute names so that different mobile device manufacturers will not use different components and attribute names to describe the same property. For example, the screen size of a cell phone is always found in the ScreenSize attribute of the HardwarePlatform component no matter its manufacturer is Nokia, Motorola or Sony Ericsson. A reference of the base components and attribute names is available at "UAProf Reference ".

The following table provides a brief description of the components that you may find in a user agent profile:

 

UAProf component

Brief description

HardwarePlatform

The HardwarePlatform component provides information about the hardware capabilities of the mobile device.

Examples: color capability, model name of mobile device, text input capability, screen size and sound capability.

SoftwarePlatform

The SoftwarePlatform component provides information about the software characteristics of the mobile device.

Examples: audio and video encoders supported, character sets accepted, Java capability, acceptable content types / MIME types and operating system name and version.

NetworkCharacteristics

The NetworkCharacteristics component provides information about the capabilities of the mobile device for network connection.

Examples: bearers supported (CSD, GPRS, SMS, EDGE...) and encryption methods supported (WTLS, SSL, TLS...).

BrowserUA

The BrowserUA component provides information about the browser of the mobile device.

Examples: mobile browser name and version, HTML version supported, XHTML version supported and JavaScript capability.

WapCharacteristics

The WapCharacteristics component provides information about the WAP features supported by the mobile device.

Examples: DRM (digital rights management) capability, maximum WML deck size, WAP version supported and WMLScript libraries supported.

PushCharacteristics

The PushCharacteristics component provides information about the WAP Push capabilities of the mobile device.

Examples: character encodings supported, character sets supported, content types / MIME types supported and maximum WAP Push message size.

MmsCharacteristics

The MmsCharacteristics component provides information about the MMS (Multimedia Messaging Service) capabilities of the mobile device.

Examples: maximum MMS message size supported, maximum image resolution supported and character sets supported.

Collection Types and Attribute Types in UAProf

In UAProf, every attribute is associated with a collection type and an attribute type. There are three collection types (Simple , Bag , Seq ) and four attribute types (Boolean , Dimension , Literal , Number ). The following two tables provide a brief description about the collection types and attribute types in UAProf:

 

Collection type

Description

Simple

An attribute of the Simple collection type has a single value. An example is the ScreenSize attribute:

<prf:ScreenSize>208x208</prf:ScreenSize>

Bag

An attribute of the Bag collection type has a list of unordered values. An example is the CcppAccept-Charset attribute, which tells us the character sets supported by a wireless device :

<prf:CcppAccept-Charset>
  <rdf:Bag>
    <rdf:li>UTF-8</rdf:li>
    <rdf:li>ISO-10646-UCS-2</rdf:li>
    <rdf:li>ISO-8859-1</rdf:li>
    <rdf:li>US-ASCII</rdf:li>
  </rdf:Bag>
</prf:CcppAccept-Charset>

Seq

An attribute of the Seq collection type has a list of ordered values. An example is the CcppAccept-Language attribute, which tells us the language preference of the user . The items are listed in order of preference. For example, the first list item is the most preferred language.

<prf:CcppAccept-Language>
  <rdf:Seq>
    <rdf:li>en</rdf:li>
    <rdf:li>de</rdf:li>
    <rdf:li>fr</rdf:li>
    <rdf:li>zh-TW</rdf:li>
    <rdf:li>zh-CN</rdf:li>
  </rdf:Seq>
</prf:CcppAccept-Language>

 

Attribute type

Description

Boolean

Yes or No .

An example is the ColorCapable attribute:

<prf:ColorCapable>Yes</prf:ColorCapable>

Dimension

Two integers equal to or greater than 0 with an "x" character in between.

An example is the ScreenSize attribute:

<prf:ScreenSize>208x208</prf:ScreenSize>

Literal

A string.

An example is the Vendor attribute:

<prf:Vendor>Nokia</prf:Vendor>

Number

An integer equals to or greater than 0. An example is the Push-MsgSize attribute, which contains the maximum WAP Push message size:

<prf:Push-MsgSize>1400</prf:Push-MsgSize>

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章