Click here to Skip to main content
12,754,607 members (35,012 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 4 Mar 2010

Using timezone webservice without WSDL

, 4 Mar 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
How to use and other raw webservices from windows mobile dotnet compact framework

The great site offers some webservices. One of these is called timezone and will give you the timezone information for a given geographic Latitude and Longitude. With a GPS enabled Windows Mobile device you can so query the webservice and get timezone informations for the current location.

Unfortunately the webservice does not offer WSDL and so you have to write your own wrapper class. I wrote a small class that does the HttpWebRequest and decodes the xml reponse for easy use in your application.

When you query the webservice you have to use the following form:

<a href=""></a>

The answer will then be:


The sample application will use this answer and shows the result:

The attached Visual Studio 2005 SmartDevice Windows Mobile 5 project has two classes: GeonamesTZ is a blocking class and geonamesTZ is a non-blocking class.

A blocking code is never good and so I implemented the class with an event. To use the class include a using statement for the geonames namespace and then initialize a new geonamesTZ object. Then add an event handler for the object’s event delegate. Finally add a event handler function that will get the timezone data.

<span style="color: #0600FF;">using</span>

To get the timezone information you have to call the class function

myGeoTZ.<span style="color: #0000FF;">startRequest</span>

and after some time the function myGeoTZ_geonamesEvent is called with the received data. Using the event driven approach will give the possibility to write an app that reads GPS data and updates timezone information in the background. Maybe this is usefull for Windows Mobile phones that often ’fly’ between continents. The timezone can then be updated in background.

As updating the UI from a different thread may fail, the updateUI function is implemented like this:

<span style="color: #008080; font-style: italic;">// see</span>
<span style="color: #0600FF;">public</span>

That was much easier than doing invokes on every txt field separately.

The raw xml response is parsed by another class called xml_helper. This class makes it easy to extract single values from the raw xml response. Here is one example:

<span style="color: #0600FF;">namespace</span>

These simple functions can be easily used on a xml file with single element data. Just call, for example getStrSettings with the xml string and the setting you would like to get.

Download Visual Studio 2005 SmartDevice Windows Mobile 5 project: DOWNLOAD:TimeZone by GPS demo application -

<!-- Social Bookmarks BEGIN --> <!-- Social Bookmarks END -->


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Germany Germany
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 4 Mar 2010
Article Copyright 2010 by hjgode
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid