Tutorials > Program model > Web services
Tutorial: Creating an Atom feed to display recipes in a remote widget
This tutorial shows you how to customize WebSphere Commerce to serve an Atom feed containing recipe information. Then we will learn how to display the recipe feed in a widget that the customers can share to social networks. For example, customers who are interested in the latest recipe collections can share a recipe widget to their Facebook page. The widget can contain links that drive traffic from Facebook back to the storefront. By creating this type of Web service feed, you are no longer limited to displaying the recipe information on store pages.
In Tutorial: Creating the Project BOD service module, you implemented the server-side customization to support a new Project service module. This service module included two nouns that represent the recipe data: the Project noun and the ProjectCollection noun. In this tutorial, we will create Atom feeds containing data from these two nouns using the Get Project and Get ProjectCollection services.
The following diagram illustrates the process of retrieving recipe data from these Web services and displaying the data in widget on a social network. In the right side of the diagram, the dotted red lines show where the recipe feed data displays in a browser and in a widget:
- 1 In the first three tutorial lessons, we will perform the customization to create Atom feeds using the Get Project and Get ProjectCollection Web services.
To format the Atom feeds, we will create feed formatting JSP files.
- 2 In the fourth lesson, we will test that the feeds are working properly by pasting the feed URLs into a browser that supports Atom feeds.
- 3 In the fifth lesson, we will learn how you can display the feed on a social network by creating a Flash widget that is a portable frame for the feed data. WebSphere Commerce uses the term remote widget for these portable frames.
- 4 In the last lesson, we will learn how to add a Share link to the Madisons recipe store page so that customers can share the recipe widget to a social network.
Learning objectives
The learning objectives for the tutorial are:
- To understand how customize the WebSphere Commerce framework that serves Atom feeds from Web services.
- To understand how the site can use Web service feeds to display store content on external sites, such as social networks.
Time required
This tutorial should take approximately three hours to finish. If you explore other concepts related to this tutorial, it could take longer to complete.
Skill level
Advanced
Audience
This tutorial is intended for WebSphere Commerce developers who are responsible for creating and customizing WebSphere Commerce services.
System requirements
Before beginning this tutorial, make sure the development machine you are using meets these requirements:
- Rational Application Developer 7.5.5.1 or higher with WebSphere Application Server 7.0.0.3 or higher is installed.
- WebSphere Commerce v7 Developer is installed.
- The Java Emitter Template (JET) package is installed
- The server setup checklist in Task flow: Remote widget setup and implementation is complete.
- The completed tutorial code is downloaded for the reference. Place it in a temporary file folder, such as TutorialSource. During the lessons, we will be instructed to copy code from this ZIP file into the project.
Prerequisites
You must complete the following tutorials so that the Project service module and the Madisons recipe pages are available on the development machine:
- Tutorial: Creating the Project BOD service module,
- Tutorial: Adding the Recipe tool to the Madisons starter store
You might also consider completing this related tutorial from the recipe series of tutorials:
To complete this tutorial you should be familiar with the following terms and concepts:
- Web services
- XML
- Relational databases
- Java classes
- JSP files
- Atom format for feeds (an alternative to RSS format)
Lessons in this tutorial
- 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.
- Run a pattern to create the Java classes for the recipe Atom feeds
In this lesson, you learn how to create two Java classes that generate Atom feeds for the four URLs you defined. One Java class will generate the two feeds from the Project noun, and the other Java class will generate the two feeds from the ProjectCollection noun. To generate the required Java class files, WebSphere Commerce provides the JET RESTful Resource pattern. You must provide XML input to the pattern, and the pattern generates the Java classes. This saves you from having to create the Java classes yourself.
- Create a feed formatting JSP file for the recipe Atom feed
In this lesson, you learn about feed formatting JSP files. The WebSphere Commerce RESTful framework uses feed formatting JSP files to format the content of an Atom feed. Each noun – Project and ProjectCollection – requires a feed formatting JSP file to get the feed data from the service data object (SDO), and to define the content of the Atom feed. The source code for each feed formatting JSP file is provided in the ZIP file you downloaded at the beginning of this tutorial.
- Test the recipe Atom feed
In this lesson, you learn how to test the four feed URLs you created in the first tutorial lesson. Now that you have created the Java classes to generate the feeds, and the feed formatting JSP files to format the feeds, the four URLs should display feed data in a client. For this test, we will use a browser as a client to display the feeds.
- Create a remote widget to display the recipe Atom feed on a social network
In this lesson, you learn how you can display recipe feed data in a remote widget. A remote widget is a Flash-based, portable frame that displays feed data. You will also learn how to share the widget to a Facebook page. By creating remote widgets, you can let customers share recipe information from the store on social networks, blogs, or other personal Web pages. The widget can contain links back to the site.
- Add a Share link to a store page so that customers can share the recipe widget
In this lesson, you learn how to give customers access to the recipe widget you created in the last lesson. On the Madisons store page that displays a Recipe Collections list, you add a Share link. When a customer clicks the Share link, the customer can customize the recipe widget and share it to a social network.