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:

<XML ID="xmlData">
<?xml version="1.0" ? >
<trees>
<tree>
<name>Aspen</name>
<height unit="foot">4</height>
</tree>
</trees>
</XML>

I'm leading to an example that shows you what to expect when you're dealing with SOAP and the XML string that it returned for this particular application. Here's an example, called a RowSchema:

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" 
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
 <s:Schema id="RowsetSchema"> 
...
 </s:Schema>
 <rs:data>
  <z:row StateID="CA" StateName="California" /> 
 </rs:data>
</xml>

The following code illustrates how I found out what the XML string looked like in my ASP page:

sXML = oProxy.GetStates()
Response.ContentType = "text/xml" 
Response.Write sXML 
Response.End

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:

Set XMLdocument = Server.CreateObject("MSXML2.DOMDocument")
Set XSLdocument = Server.CreateObject("MSXML2.DOMDocument")
...
if InStr(Request.ServerVariables("HTTP_USER_AGENT"), "Mozilla") then 
   ...
else 
    'WAP guy 
    Response.ContentType = "text/vnd.wap.wml" 
    xslfile = "../XSL/stateWml.xsl"
    XSLdocument.async = false
    XSLdocument.load(Server.MapPath(xslfile))
strResult=XMLdocument.transformNode(XSLdocument.documentElement)
Response.Write strResult 
Response.End 
end if
   Prev. page   [1] 2     next page
 
 

ADS BY GOOGLE