Develop > Presentation layer > Work with Web service feeds > Create a custom feed from a Web service


Define the URL and creating the Java class for the feed

Use a specific URL structure, define the URL for the RESTful HTTP Get request to retrieve data from the Web service. You must define the URL so that you can use certain data in the URL to create the Java class that supports the feed. When the customization is complete, the URL you define will display the Atom feed if you paste it into a feed reader or browser that supports Atom feeds.


Before you begin

To generate the required Java class file, WebSphere Commerce provides a pattern that uses a Java Emitter Template (JET). You provide XML input to the pattern using data from the URL you define, and the pattern generates the Java class that is the JAX-RS resource. This saves you from having to create the Java class yourself.


Procedure

  1. Define the URL for the custom feed:

    1. Open an empty file in a text editor, and paste the following basic URL structure into the file:

      http://host/wcs/resources/stores/storeId/plural_noun_name/identifier

    2. Replace the variables in the URL (shown in italic font) with actual values for the feed. For information about the variables and for example URLs, see URL structure for Web service feeds.

    3. Add to the URL any optional query parameters to override default parameters, if required. For example, the URL will require the parameter responseFormat=atom to retrieve an Atom feed.

      When you finish defining the URL, the result might look similar to this example, which returns an Atom feed containing data from the Catalog noun for a specific catalog that has an external ID of 99999:

      http://mysite.example.com/wcs/resources/stores/10101/Catalogs/99999?responseFormat=atom

  2. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.

  3. Create the pattern input file:

    1. Right-click the WebSphereCommerceServerExtensionsLogic project and select New > Folder.

    2. Type RestInterfaceDefinition as the folder name. This creates a single location to store all RESTful Resource pattern input files.

    3. Right-click the RestInterfaceDefinition folder and select New > File.

    4. Type a name for the file using the syntax name_of_noun.xml, for example, Catalog.xml.

    5. Click Finish.

    6. Define the pattern input file in this file. For more information, see JET RESTful Resource pattern input file and the Java class it generates.

    7. Save the file.

  4. Right-click the pattern input file and select Run As > Input for Jet Transformation.

  5. In the Transformation section:

    1. Select the following ID, which is the JET RESTful Resource pattern:

      com.ibm.commerce.toolkit.internal.pattern.rest

    2. Click Run.
    The pattern generates the Java class that is the JAX-RS resource and places it at the location specified in the pattern input file.

  6. Register the new Java class to the JAX-RS runtime:

    1. Open the properties file at this path:

      WCDE_INSTALL/workspace/Rest/WebContent/WEB-INF/config/resources-ext.properties

    2. In the properties file, add the fully qualified name of the Java class the pattern created, for example:

      com.mycompany.commerce.Catalog.rest.resources.Catalog

    3. Save and close the file.

    4. Restart the WebSphere Commerce server.


Next topic: Create the Atom feed representation of the service


Related tasks

Install the Java Emitter Template (JET) package


+

Search Tips   |   Advanced Search