O'Reilly logo

Object-Oriented Programming with Visual Basic .NET by J.P. Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.6. Accessing Data for the Web Service

A production version of the ZipService would probably use a database like SQL Server or Oracle to provide data for the service. To keep the example self-contained, an XML file (shown in Example 10-7) containing zip code information is used. The file contains only partial data for two cities, but can easily be extended if desired.

Example 10-7. Partial zip code data for Houston and Austin
<?xml version="1.0" ?>
<cities>
    <city name="Houston">
        <zip>77002</zip>
        <zip>77003</zip>
        <zip>77004</zip>
        <zip>77005</zip>
        <zip>77006</zip>
    </city>
    <city name="Austin">
      <zip>78742</zip>
      <zip>78744</zip>
      <zip>78746</zip>
      <zip>78748</zip>
      <zip>78750</zip>
    </city>
</cities>

10.6.1. Typed DataSet

The implementation does not use the XML directly. Instead, a typed DataSet is created to handle data access. A DataSet provides a consistent relational programming model that is independent of a data source. This means that, once a DataSet is populated, where the data came from is irrelevant. By coding against a DataSet, the data source can be changed at a later time without negatively impacting the web service

The XML Schema Definition Tool that ships with the .NET Framework SDK (xsd.exe) does most of the work. This tool can generate an XSD schema that describes the XML in Example 10-7. In turn, that schema can build a derived DataSet class that allows the XML to be manipulated programmatically.

Building a DataSet with this tool is a three-phase process. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required