Tutorials > Program model > Web services > Create an Atom feed to display recipes in a remote widget
Define URLs for recipe Atom feeds
In this lesson, you learn how to define the URLs for various types of recipe feeds. Each URL is an address that a client can use to request a feed for a specific noun. The two nouns used in this lesson are the Project noun and the ProjectCollection noun. You must define the feed URLs first, because in the next lesson, specify certain data from the URLs in the Java classes that generate the feeds.
Read the following topics so that you have the background knowledge required to understand the lesson:
If you need a refresher on the Project service module, and the Project and ProjectCollection nouns, review Tutorial: Creating the Project BOD service module,
You are going to define URLs for four different recipe feeds. This way, the store has a variety of feeds available to display recipe information to customers in feed readers and widgets.
The first and second feeds contain data from the Project noun:
- Feed 1: Contains a list of all recipes.
- Feed 2: Contains a specific recipe, for example, the Penne Pasta Salad recipe.
The third and fourth feeds contain data from the ProjectCollection noun:
- Feed 3: Contains a list of all recipe collections.
- Feed 4: Contains a specific recipe collection, for example, the Delicious Foods collection.
Procedure
- Use the basic RESTful URL structure you read about in URL structure for Web service feeds, define the URLs for Feed 1 and Feed 2, which both contain data from the Project noun:
- The URL for Feed 1 is:
http://host_name/wcs/resources/stores/storeId/Projects?responseFormat=atom
- The URL for Feed 2 is:
http://host_name/wcs/resources/stores/storeId/Projects/projectIdentifier?responseFormat=atom
Notes on these URLs:
- The WebSphere Commerce convention is to use the pluralized name of the noun in the feed URL. This is why the URLs contain Projects rather than Project.
- Notice that the two URLs are almost identical because Feed 1 and Feed 2 both contain data from the same store and the same Project noun. The only difference is that the Feed 2 URL includes projectIdentifier. By including projectIdentifier in the URL, Feed 2 will contain data from the Project noun for a specific recipe, that is, the recipe that matches the projectIdentifier value.
- Now define the URLs for Feed 3 and Feed 4, which contain data from the ProjectCollection noun:
- The URL for Feed 3 is:
http://host_name/wcs/resources/stores/storeId/ProjectCollections?responseFormat=atom
- The URL for Feed 4 is:
http://host_name/wcs/resources/stores/storeId/ProjectCollections/projectCollectionIdentifier?responseFormat=atom
Notes on these URLs:
- The WebSphere Commerce convention is to use the pluralized name of the noun in the feed URL. This is why the URLs contain ProjectCollections rather than ProjectCollection.
- Notice that the two URLs are almost identical because both Feed 3 and Feed 4 contain data from the same store and the same ProjectCollection noun. The only difference is that the Feed 4 URL includes projectCollectionIdentifier. By including projectCollectionIdentifier in the URL, Feed 4 will contain data from the ProjectCollection noun for a specific recipe collection, that is, the recipe collection that matches the projectCollectionIdentifier value.
This lesson introduced how to form URLs for feeds from specific nouns. In the next lesson, we will use data from the URLs you defined as input to the Java classes that will generate the Web service feed.