Compartir a través de


How to: Use OData to Return/Obtain an AtomPub Document

When you register an OData web service, you expose an OData service that can be accessed from a uniform resource identifier (URI) by using a web browser or any other HTTP client. OData clients can use Atom Publishing Protocol (AtomPub) documents to interact with Microsoft Dynamics NAV data. AtomPub is a simple HTTP-based protocol for creating and updating web resources. It is related to the Atom Syndication Format, which is XML for web feeds. In these procedures, you obtain different kinds of AtomPub documents or feeds from a Microsoft Dynamics NAV OData web service. AtomPub documents and feeds are XML.

Note

To use the URIs in this topic, you must have access to the CRONUS International Ltd. demonstration database.

Obtaining an AtomPub Document or Feed

Depending on how you construct your URI, you can return an AtomPub document or an AtomPub feed. A feed is a request for data that can change over time. For example, this can be news content or other kinds of information. In the case of Microsoft Dynamics NAV, the information is database content.

To obtain an AtomPub document or feed

  1. Register and publish a page web service by using the RoleTailored client. For more information, see Walkthrough: Creating and Interacting with a Page Web Service (OData).

    The AtomPub documents that are shown in the walkthrough are based on the page 21, the Customer Card page, with Customer as the service name. The concepts and steps are the same for any RoleTailored client page that you register and publish as a web service.

    Note

    You can also register and publish a Microsoft Dynamics NAV query as a web service.

  2. Start Windows Internet Explorer. In the Address field, enter a URI in this format:

    http://<Server>:<WebServicePort>/<ServerInstance>/OData
    

    If Microsoft Dynamics NAV Server is running on the local computer with the default Microsoft Dynamics NAV Server instance and OData port, then the address is:

    https://localhost:7048/DynamicsNAV90/OData
    

    The browser should now show the web service that you have published in the format of an AtomPub document:

    Basic AtomPub document for a page

  3. If you have multiple companies, then you can modify your URI to return a feed that enumerates all available companies:

    https://localhost:7048/DynamicsNAV90/OData/Company
    

    Important

    You must modify your Internet Explorer settings to display the actual XML for a feed instead of the feed content that has changed. Choose Internet Options, choose Content, choose Feeds and Web Slices, and then clear the Turn on feed reading view check box. Restart Internet Explorer to enable the new setting.

Obtaining a Keyed Service Entry

With a keyed service entry, you specify content from a particular row in a Microsoft Dynamics NAV table. The AtomPub document will contain information that is specific to that row. This procedure assumes that you have registered and published a page web service in the previous procedure.

To obtain a keyed service entry

  1. Start Windows Internet Explorer. In the Address field, enter a URI in the following format to get the entry for the CRONUS International Ltd. company:

    https://localhost:7048/DynamicsNAV90/OData/Company('CRONUS%20International%20Ltd.')
    
  2. To get the data feed for the Customer table in the CRONUS International Ltd. company database, enter a URI in the following format:

    https://localhost:7048/DynamicsNAV90/OData/Company('CRONUS%20International%20Ltd.')/Customer
    
  3. To additionally constrain data to a specific keyed customer in the Customer table, enter a URI in the following format, using the customer no. for the record you want. The example uses customer no. 01121212:

    https://localhost:7048/DynamicsNAV90/OData/Company('CRONUS%20International%20Ltd.')/Customer('01121212')
    

Obtaining a Filtered Data Feed

With a filtered data feed, you use special syntax in the URI to define a query on the available data. For details on the specific filters available for Microsoft Dynamics NAV OData web service applications and the syntax for using them, see Using Filter Expressions in OData URIs.

To obtain a filtered service data feed

  1. Start Windows Internet Explorer. In the Address field, enter a URI in the following format to get the entry for the CRONUS International Ltd. company:

    https://localhost:7048/DynamicsNAV90/OData/Company('CRONUS%20International%20Ltd.')/Customer?$filter=City%20eq%20'Birmingham'
    

See Also

Concepts

OData Web Services