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
- Start WebSphere Commerce Developer utility
- Open Java EE perspective and select the Enterprise Explorer view.
- Go to the WCDE_installdir\workspace\Rest\WebContent\WEB-INF\config directory.
- Right-click the config folder and
create an extension folder called com.ibm.commerce.rest-ext
- 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.
- Save and close the file.
- Restart your test server.
- Verify that REST has access to warranty information.
- Launch poster for Firefox..
- In the URL field, input your URL for the product with
warranty information.
http://hostname/wcs/resources/store/storeid/productview/byId/productId
- 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.
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.