Creating the custom access profile to get the UserData from REST service

In this lesson, you create an extended configuration file to retrieve warranty information from REST service.

About this task

REST services are built on top of OAGIS services. REST services use an access profile and XPath to get data from an OAGIS noun. The access profiles that are used by REST services are defined in the Rest.war/WEB-INF/config/com.ibm.commerce.rest/wc-rest-resourceconfig.xml. You can extend the configuration files to overwrite the data mapping, Rest.war/WEB-INF/config/com.ibm.commerce.rest-ext/wc-rest-resourceconfig.xml.

Procedure

  1. Start WebSphere Commerce Developer utility
  2. Open Java EE perspective and select the Enterprise Explorer view.
  3. Go to the WCDE_installdir\workspace\Rest\WebContent\WEB-INF\config directory.
  4. Right-click the config folder and create an extension folder called com.ibm.commerce.rest-ext
  5. Create a custom configuration file called wc-rest-resourceconfig.xml. Copy the following snippet into the file:
    <?xml version="1.0" ?>
    <!--
    Define the custom access profile to get the user data information from REST service.
    -->
    <ResourceConfig>
      <Resource name="productview">
       <GetUri 
         uri="store/{storeId}/productview/byId/{productId}" 
         description="Get product by unique ID" 	
         accessProfile="MyCompany_Store_Warranty" 
         searchProfile="X_findCatalogEntryWarranty"/>
      </Resource>
    </ResourceConfig>
    In the extended configuration file, specify the following information:
    • The resource to be customized. In this scenario, the resource name is productview since Warranty is added against the product level.
    • The GetUri you want to customize. In this scenario, retrieve the data by using productId.
    • The description. In this scenario, the description is to get product by part number.
    • The access profile. The extended access profile controls the amount of data that the expression builder returns.
    • The search profile. The extended search profile retrieves the user data information from the search index.
    For more information, see Customizing and configuring REST resources using the BOD mapping framework.
  6. Save and close the file.
  7. Restart your test server.
  8. Verify that REST has access to warranty information.
    1. Launch poster for Firefox..
    2. In the URL field, input your URL for the product with warranty information.

      http://hostname/wcs/resources/store/storeid/productview/byId/productId


      Hit the URL to test
    3. Press GET.
      The user data is retrieved through productId number 17101 via REST service. Ensure that you see xcatentry_WARRANTYTERM and xcatentry_WARRANTYTYPE in the results.

      REST service response with warranty term and warranty type displayed.

Results

By verifying through poster, you successfully created a custom access profile to get userData from REST services. You are ready to proceed to the next lesson.