1. WCF Data Services and Publicly Consumable Data Feeds
Windows Azure Marketplace DataMarket,
is a service Microsoft offers through Windows Azure that facilitates
the publishing and hosting of data by using Windows Communication
Foundation (WCF) Data Services, so organizations and individuals can
consume that data via a subscription model. For example, you’ll use the U.S. Crime Data statistics data service (DATA.gov)
to build a dashboard in SharePoint by using Microsoft Excel Services,
and then integrate that data into SharePoint by using a WCF service.
There are, of course, many types of DataMarket data feeds that you can
explore and use in your application development.
Through the Marketplace
DataMarket, you can publish data sets to the cloud, host them on Windows
Azure, and then facilitate consumption of your data feed by using
Representational State Transfer (REST). REST provides lightweight access
to web-based data by using various standards or protocols, such as the
Open Data Protocol (oData). oData applies web technologies such as HTTP, the Atom Publishing Protocol (AtomPub), and JavaScript Object Notation (JSON)
to access information from different web-based sources. These web-based
sources can range from relational databases and file systems to web and
content management systems—and of course, include information that
resides in normal websites. An open-standards protocol provides guidance
on oData through the site http://www.odata.org/. Using oData, you can both publish and consume data feeds. You can publish data by using WCF
Data Services, and you can consume it using REST Uniform Resource
Identifiers (URIs) that expose the data in different formats (such as
AtomPub). The results can be consumed by a browser or used in
application development.
Microsoft provides a free-for-use oData data set (called Northwind), available at http://services.odata.org/Northwind/Northwind.svc/Customers.
When you navigate to this URI by using your web browser, the returned
customer data looks similar to the XML code snippet shown in Example 2-1. (You should take note that, by default, Windows
Internet Explorer and many other browsers render this as an RSS feed,
so you may have to turn this return data feed off to see the data as
XML.)
Note:
The returned XML data shown in Example 1 is a trimmed snippet from the full returned data and includes only two customers: ALFKI and ANATR.
Example 1. Two-customer snippet of the full customer XML from Northwind
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <feed xml:base="http://services.odata.org/northwind/Northwind.svc/" xmlns:d="http:// schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> <title type="text">Customers</title> <id>http://services.odata.org/Northwind/Northwind.svc/Customers</id> <updated>2010-11-27T20:34:27Z</updated> <link rel="self" title="Customers" href="Customers" /> <entry> <id>http://services.odata.org/northwind/Northwind.svc/Customers('ALFKI')</id> <title type="text" /> <updated>2010-11-27T20:34:27Z</updated> <author> <name /> </author> <link rel="edit" title="Customer" href="Customers('ALFKI')" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="Customers('ALFKI')/Orders" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/ related/CustomerDemographics" type="application/atom+xml;type=feed" title="CustomerDemographics" href="Customers('ALFKI')/CustomerDemographics" /> <category term="NorthwindModel.Customer" scheme="http://schemas.microsoft.com/ ado/2007/08/dataservices/scheme" /> <content type="application/xml"> <m:properties> <d:CustomerID>ALFKI</d:CustomerID> <d:CompanyName>Alfreds Futterkiste</d:CompanyName> <d:ContactName>Maria Anders</d:ContactName> <d:ContactTitle>Sales Representative</d:ContactTitle> <d:Address>Obere Str. 57</d:Address> <d:City>Berlin</d:City> <d:Region m:null="true" /> <d:PostalCode>12209</d:PostalCode> <d:Country>Germany</d:Country> <d:Phone>030-0074321</d:Phone> <d:Fax>030-0076545</d:Fax> </m:properties> </content> </entry> <entry> <id>http://services.odata.org/northwind/Northwind.svc/Customers('ANATR')</id> <title type="text" /> <updated>2010-11-27T20:34:27Z</updated> <author> <name /> </author> <link rel="edit" title="Customer" href="Customers('ANATR')" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="Customers('ANATR')/Orders" /> <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/ related/CustomerDemographics" type="application/atom+xml;type=feed" title="CustomerDemographics" href="Customers('ANATR')/CustomerDemographics" /> <category term="NorthwindModel.Customer" scheme="http://schemas.microsoft.com/ ado/2007/08/dataservices/scheme" /> <content type="application/xml"> <m:properties> <d:CustomerID>ANATR</d:CustomerID> <d:CompanyName>Ana Trujillo Emparedados y helados</d:CompanyName> <d:ContactName>Ana Trujillo</d:ContactName> <d:ContactTitle>Owner</d:ContactTitle> <d:Address>Avda. de la Constitución 2222</d:Address> <d:City>México D.F.</d:City> <d:Region m:null="true" /> <d:PostalCode>05021</d:PostalCode> <d:Country>Mexico</d:Country> <d:Phone>(5) 555-4729</d:Phone> <d:Fax>(5) 555-3745</d:Fax> </m:properties> </content> </entry> ... <link rel="next" href="http://services.odata.org/Northwind/Northwind.svc/ Customers?$skiptoken='ERNSH'" /> </feed>
|
You can, for example, issue queries through a specific REST query syntax to return more detailed information. For example, http://services.odata.org/Northwind/Northwind.svc/Customers(‘ALFKI’) returns only the information for the customer with the ID ALFKI.
Note:
More Info To learn more about oData, visit http://www.odata.org/.
After the data has
been returned to the calling application, you can parse the XML and use
the underlying data in your application. To do this, you would use
standard XML objects (such as XDocument or XElement)
or custom classes and list collections to manage the data internally in
your application.
As mentioned earlier, you use WCF
Data Services (formerly Microsoft ADO.NET Data Services) to expose a
data set for public (or subscription) consumption.You’ll use services that have already been published to the DataMarket
by using WCF Data Services, and you’ll learn how to consume those
services in your applications.
Note:
More Info To learn more about WCF Services, visit http://msdn.microsoft.com/en-us/library/cc668794.aspx.