Using the Openwave MMS SDK to Query Device Capabilities
This month in Jack's Hack we'll take a look at a feature of the Openwave MMS Library which allows developers
to query information about devices. One of the challenges in building MMS applications is knowing what type of
device is actually in the hands of the end user. Since each device may have slightly different display capabilities and
formats supported which need to be kept in mind when building applications. The Openwave MMSC does contain a transcoder
that will rescale/reformat images to fit the display of any device, but if a developer know the target device ahead of time
the transcoding step can be skipped and/or made more optimal (e.g. not deliver a horizontally oriented image to a vertically
oriented display).
The DeviceProfileRequest method that is part of the Openwave MMS SDK 2.1 provides a clean and easy way
to query the device database on the Openwave MMSC. The only information that is needed is the phone number of the subscriber, and
the response will contain the URL to the device profile of the last konwn device that is associated with that particular phone
number. The information contained in the MMSC is updated every time a user connects, and is immediately availble. It is worth noting
that before a user connects, the information may not be pre-populated. This is not likely a concern in a production deployment, but
should be kept in mind when using the developer MMSC (skara.openwave.com).
Getting Started
To test out querying the device capabilities of the make sure that you've downloaded the Openwave Phone Simulator 6.2.2 and
the WAP 1.x Network Plugin. You will also need the Openwave MMS SDK 2.1
If you've not done so already, make sure that you've provisioend the SDK on the Openwave MMSC. For the details on getting setup,
take a look at the MMS Quickstart Guide.
Once you have all of the tools in place, take a look at the GetDeviceProfile.java file that is in the samples/standalone
directory from the Openwave MMS SDK. The class if very simple, and makes are request to the MMSC, and prints out the response
to the console
try {
// create a connection to the mmsc
RelayConnection conn = RelayConnection.createSender( mmscUrl, userName, password );
// now create a DeviceProfileRequest object, use the connection object created earlier
// to send it to the relay
DeviceProfileRequest request = createDeviceProfileRequest(targetUser, userName);
// now send the request using the connection created above
Response response = conn.sendRequest( request );
printResponse( response, targetUser );
The response which comes back from the MMSC will contain one of three things. If all is well, and as expected the URL
to the device provifile will be passed back Profile URL:
The GetDeviceProfile class takes the extra effort of also extracting out the Device information from the XML response that comes back from the MMSC.
Information for user 16504804320
Profile URL: http://developer.openwave.com/uaprof/OPWVSDK62.xml
If there is not a UAProf document for the give device, the User-Agent string is returned instead. If the device is completely
unkonwn to the MMSC, a response of Unknown Device is returned. Once you have the UAProf URL, your application can then
either fetch and parse the information (see
Jack's Hacks from February for more on UAProf). In our case if we can dig into the UAProf for the Openwave Phone Simulator and
see that we have a display size of 160x120 for MMS content
The getdev.bat/getdev.sh files in the samples/standalone directory provide a quick and easy way to test this functionality and
so you can see what the response is going to be like. Please note, that unlike the other standlone samples in the directory, these
getdev tools read the VASP ID, VASP Password, and MMSC URL from the SimpleSender.properties file instead of
off of the command line. It is also worth noting that the response and
request to extract the Device Profile information is done by extending the
capabilities of the MM7 interface. As such, the method described in this
hack (and in the documentation for the Openwave MMSC SDK) is supported
only on the Openwave MMSC.
If you are interested in building sophisticated MMS Applications and do not want to rely on transcoding of your content, or if
you want to make sure that the content your applications deliver have an appropriate orientation for the device they target, this
simple method can take much of the guess work out of getting MMS content right.