Accessing OData Feeds from a Web Browser (WCF Data Services Quickstart)

In this first task, you will retrieve the service definition document from the public Northwind sample data service hosted on the OData.org website. You will then access specific Northwind resources by using the Open Data Protocol (OData) to submit HTTP GET requests through a Web browser to the exposed resources. You will optionally also disable feed reading in the Web browser.

To request the default service document and metadata document by using Internet Explorer

  1. In Internet Explorer, from the Tools menu, select Internet Options, click the Content tab, click Settings, and clear Turn on feed viewing.

    This makes sure that feed reading is disabled. If you do not disable this functionality, then the Web browser will treat the returned AtomPub encoded document as an XML feed instead of displaying the raw XML data.

    Note

    If your browser cannot display the feed as raw XML data, you should still be able to view the feed as the source code for the page.

  2. In Visual Studio, press the F5 key to start debugging the application.

  3. Open a Web browser on the local computer. In the address bar, enter the following URI:

    http://services.odata.org/Northwind/Northwind.svc/
    

    This returns the default service document, which contains a list of entity sets that are exposed by this data service.

  4. In the address bar, enter the following URI:

    http://services.odata.org/Northwind/Northwind.svc/$metadata
    

    This returns the data service metadata, which describes the entity-relational model exposed by this data service.

To access entity set resources from a Web browser

  1. In the address bar of your Web browser, enter the following URI:

    http://services.odata.org/Northwind/Northwind.svc/Customers
    

    This returns a set of all customers in the Northwind sample database.

  2. In the address bar of your Web browser, enter the following URI:

    http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')
    

    This returns an entity instance for the specific customer, ALFKI.

  3. In the address bar of your Web browser, enter the following URI:

    http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Orders
    

    This traverses the relationship between customers and orders to return a set of all orders for the specific customer ALFKI.

  4. In the address bar of your Web browser, enter the following URI:

    http://services.odata.org/Northwind/Northwind.svc/Customers('ALFKI')/Orders?$filter=OrderID eq 10643
    

    This filters orders that belong to the specific customer ALFKI so that only a specific order is returned based on the supplied OrderID value.

Next Steps

You have successfully accessed the sample Northwind data service from a Web browser, with the browser issuing HTTP GET requests to specified resources. A Web browser provides an easy way to experiment with the addressing syntax of requests and view the results. However, a production data service is not generally accessed by this method. Typically, applications interact with the data service through application code or scripting languages. Next, you will create a simple client application that uses client libraries to access data service resources as if they were common language runtime (CLR) objects:

Consuming OData Feeds in a Console Application

See Also

Concepts

Accessing an OData Service (WCF Data Services)