The WAP Traffic Application

With a little help from Simple Object Access Protocol (SOAP), XML, Extensible Style Language (XSL), Wireless Markup Language (WML), and Active Server Pages (ASP), the Wireless Access Protocol (WAP) traffic application is ready! That's right—no more getting up early to watch various news broadcasts with the hopes of catching the traffic update. From your Web-enabled phone or other WAP device, you can now receive up-to-the minute traffic reports (currently, San Diego is the only city available).

To pull this off, I had to find data that exists in a format that would let me extract it and combine it with WML to produce output suitable for a WAP device. Terry Givens described a Web service he created using the SOAP Toolkit in the November 28 XML UPDATE Commentary, and I decided to use that to get the XML data file for the traffic application.

I used the Remote Object Proxy Engine (ROPE) to call the Web service methods that return the XML data. Once I had the string, I needed a way to query the XML document. But first, I had to determine the type of XML document I was dealing with. Here's the document that I was testing with:

I could see the data, but I still had to figure out how to get to it and present it. For this, I created a couple of XMLDOMDocument objects. I used the same ASP page for both the Web browser and WAP browser versions; I detected the different user agents and called different XSL style sheets accordingly:

At this point, I ran into difficulties creating the style sheets to transform the XML data into WML output. Also, I wondered what means to use to refer to the elements and attributes in the source tree. One problem was that I didn't understand the XSL namespace declarations, as the following code illustrates:

Using this declaration, the WML Parser kept producing errors that referred to the DOCTYPE and other elements in the declaration. I knew that some type of transformation was occurring because "Yeh Baby" (which I included for debugging purposes) kept appearing in the emulator information box. As I read up on XSL declarations and namespaces, it occurred to me that a lot of this declaration was unnecessary for my purposes. Finally, on MSDN I found an example that helped:

Voila! My data! The problem with the previous declaration—at least for my application—was the way the WML Document Type Definition (DTD) was wrapped in the CDATA section. The MSDN example used the XSL namespace to define a DOCTYPE element and used the WML DTD as the element's value.

If you remember in the RowSchema example, the actual data was not a value of the element tag per se (<element>value</element>); it was the value of the attribute element:

<rs:data> <z:row StateID="CA" StateName="California" /> </rs:data>

To get to this point, I used XPATH, which lets you get the exact information you want by way of XPATH expressions. You specify a starting point (context node) and a location path (xml/rs:data/z:row), and from there, you specify the following to get the data:

From the Blogs

My initial goal in writing this series of posts was to outline some of the concerns surrounding Availability Groups (AGs) and SQL Server Agent Jobs – and call out how there is virtually no guidance from Microsoft on this front and then detail some of the pitfalls and options available for tackling this problem domain. I initially expected this series of posts to have between 25 and 30 posts – according to some of the early outlines I created ‘way back when’....More

Throughout this series of posts I’ve taken a somewhat pessimistic view of how SQL Server Agent jobs are managed within most organizations – meaning that most of the code and examples I’ve provided up until this point were based on assumptions about how CHANGE to jobs is managed. That pessimism, to date, has come in two forms:...More

In this series of posts I’ve called out some of the concerns related to SQL Server AlwaysOn Availability Groups and their interaction with SQL Server Agent jobs – both in the form of Batch Jobs (see post #3) and backups....More