XML - Managing Data Exchange/SyncML

Learning objectives
Upon completion of this chapter, you will be able to


 * Understand SyncML fundamentals and general syntax.
 * Understand how and why SyncML is implemented.
 * Quickly locate and use SyncML technical specifications.

Introduction
Mobile devices such as PDAs, pagers, mobile phones and laptops are- by nature- not always connected to a network. Yet these devices contain applications which require information obtained from a network in order to be useful. While most PDAs and mobile phones contain applications such as calendars, task lists, and address books for storing useful information, this information is far less useful when it is static, only available on the device itself. For example, copies of static information will always be dissimilar when changes are made on one copy or the other. Synchronization offers a device the ability to connect to a network in order to update either the information on the device or the information on the network, such that both sets of information are identical and up-to-date.

Given the proliferation of proprietary mobile devices and protocols, as well as the increasing consumer demand for ubiquitous mobile access of information, leading technology companies saw the need to create a standard, universal language for describing the synchronization actions between devices and applications. They formed a consortium to sponsor the SyncML initiative to create this language.

Currently, the SyncML consortium has been adopted and incorporated into the Open Mobile Alliance, a larger group of over 300 companies which sponsors many collaborative technology projects and protocols.

What is SyncML?
SyncML or Synchronization Markup Language is an XML-based, industry-standard protocol for synchronizing mobile data across a variety of multiple networks, platforms and devices. SyncML started as an initiative in mid 2000 by major technology companies such as Ericsson, IBM, Palm Inc., Lotus, Matsushita Ltd. (Panasonic), Motorola, Nokia, Openwave, Starfish Software, Psion and Symbian. Their initiative's goals were to create a universal language from the myriad, proprietary, synchronization protocols used by mobile devices and provide a complete set of synchronization functionality for future devices. The consortium released version 1.0 in December 2000. They then implemented new features and resolved issues with the subsequent version releases, finalizing the protocol with version 1.1 in February 2002.

The SyncML protocol is designed with these goals in mind:


 * As a common language, any device should be able to synchronize with any SyncML service (a networked data repository).
 * Any service speaking SyncML should be able to synchronize with any SyncML-capable device.
 * The protocol must address the limitations of mobile devices, specifically with respect to memory storage.
 * It must support a variety of transport protocols such as HTTP, SMTP, Bluetooth and others.
 * It must deliver common synchronization commands to all devices.
 * It builds upon existing web technologies, specifically XML.
 * Support asynchronous communication and error-handling, since the Internet has latency.

SyncML consists of client and server commands enclosed within DTD-defined...

Vocabulary
Let's begin by defining a vocabulary:


 * Client - the mobile device, its application and local database.
 * Server - a remote system communicating to the system database or application.
 * Modifications - data in fields in a database are changed.
 * Sync - The client and server exchange SyncML messages with commands.
 * Package - SyncML DTD conformant XML markup describing requests or actions to be taken by either a SyncML client or server. A package is a collection of actions to be performed
 * Message - the smallest unit of SyncML markup. Large packages are broken into separate messages.
 * Mapping - using an intermediate identifier to tie two pieces of information together. example: let's say 'green' is '5', and '5' is nice.  What is nice?  If you said 'green' you are correct. You've just done mapping!

Abbreviations:

Messages and Packages
SyncML messages are requests from either a client or server to perform some action. The action may be to synchronize data, perform some checks on data, update a status, or handle any errors with these actions. Messages are bundled together as packages, as kind of a to-do list. Messages are a laundry list of requests, and they can be pieced together out of order if sufficient mapping information is given to identify to which package the message belongs.

SyncML is designed this way to accommodate for errors and dropped messages. Should one message be dropped, a syncML client or server will know there is a problem because the mapping cannot be completed. It will then issue a request for the information to be resent. Once the data is received, the updates to the information can proceed.

Structure of a SyncML message
Like SOAP, there are two parts to the SyncML message, a Sync Header  and Sync Body . The header contains meta-information about the request, such as the target database  and source database datafield and data an existing data field with some data   
 * }

Notice lines {1} and {18} start the SyncML file with the root tags. Next, the SyncHdr is defined by lines {2} and {8}. Further, lines {3,4} define the versioning information, line {5} defines the sessionID to distinguish which unique dialogue is occurring between client and server applications, line {6} shows the MsgID to uniquely identify this set of requests (this entire markup) to be performed by the requested application. Also in the syncHeader are credentials, on line {7}.

The SyncBody begins on line {9}. In this part of the syncML message, device/application status {10}, target/source URIs {12,13}, and requested actions such as the sync itself between lines {11,16}, Add and Replace {14,15} commands are given.

WBXML and SyncML
WAP Binary XML (WBXML) is a form of XML whereby the XML tags are abbreviated in order to shorten the markup for transmission to mobile devices, which commonly have bandwidth and memory limitations. The XML tags are encoded into a binary shorthand to save space. Let's take a look at an example so that this will make more sense.

The following is WBXML binary code depicting a SyncML message. Notice in the first line there is a the document type definition, represented here in hexadecimal tokens. Can you see what happens to the following string? "//SYNCML//DTD SYNCML 1.1//EN"



Immediately following this string are the characters '6D 6C 71'. Each of these represent a SyncML tag.

wbxml abbreviations

wbxml abbreviations (cont.)

tells the SyncML processor that this is the beginning of opaque (xml) data this represents the length of this opaque data The characters "1" followed by "." and "1" represents ""

All together this WBXML code snippet, 6D6C71C303"1.1"01 represents:

SyncML header snippet

So you can see how using WBXML shorthand would be a more compact means of representing XML, saving bandwidth for mobile devices.

For more information please refer to Ed Dumbill's articles on syncML with WBXML:
 * Have Data, Will Travel
 * WBXML and SyncML

SyncML specifications
The best source of information on SyncML is the protocol itself. Visit the Open Mobile Alliance for the SyncML specifications.

Open Mobile Alliance
Download OMA SyncML Specifications and white papers at the Open Mobile Alliance. Or check out the SyncML Articles at the Open Mobile Alliance.

SyncML Implementations
Although the SyncML specifications are useful, you still have to implement the protocol in your application. There are a few toolkits and implementations out there that you can use to get a head start.

SyncML Reference Toolkit
The Open Mobile Alliance has released a toolkit written in C to demonstrate SyncML. You can get it here. If you can read German, you can get a sample application using the toolkit here.

Funambol
Interested in developing SyncML for Java? Check out the open source project Funambol. It offers a Java and C++ SDK that implements the SyncML data synchronization protocol, a Java-based application framework for building SyncML server applications, and a standalone SyncML server.

Summary
Mobile Device Technology is improving and changing at a rapid pace. As US telecommunication companies implement Third generation (3G) WCDMA technology (wide-band code-division multiple access), or wireless broadband, we will begin to see powerful devices emerge on the market. These devices will be able to deliver full color, video, streaming multimedia and a variety of data services such as Multimedia Messaging Service (MMS) through WAP. In that infrastructure is becoming cheaper, these telecommunication companies are starting to shift towards being service providers and media vendors as opposed to communications utilities. Cingular wireless, multimedia messaging and ringtones services are a good example of the shift of their company towards being a media platform. The companies that will survive will be the ones that listen to customers needs and make easy-to-use services.

Telecommunications companies can add value to their services by creating custom applications and services that use SyncML for synchronization.

Exercises

 * 1) Visit the Open Mobile Alliance Website, download the pdf of the SyncML v. 1.1 protocol and review it.  Reading this reference is a valuable exercise in learning.
 * 2) Answer these questions:
 * 3) * What is WBXML and why is it used?
 * 4) * How do you foresee SyncML being used in the future?
 * 5) * Name a problematic situation whereby SyncML is the best 'tool' for the job.

''Answers: 2a) WBXML is Wap Binary XML, it is a form of XML whereby the XML tags are abbreviated in order to shorten the markup for transmission to mobile devices, which commonly have bandwidth and memory limitations. 2b) SyncML will likely be used as a general, standard syncing mechanism for synchronizing data sets between systems, not just for mobile devices. 2c) A ticket-tracking system called TNT helpdesk is a web-based open work request management system. The staff running this system would like to have live data from this system on their PDAs, listing open requests.  Currently, the PDA database is synced via a docking sync station attached to the staff members' PCs.  Staff members have to download the request list as a CSV file, convert it into a usable PDA database and upload it to the PDA, making it this process cumbersome, prone to error, and always out-of-date.  Recommendation: Create a custom app to push live updates to the PDAs using SyncML over Bluetooth/Wireless''