Verifying your new REST service call by using the Poster browser plug-in
In this lesson, you verify the new REST calls to the sample data beans and controller commands with the Poster browser plug-in.
Note: This
lesson verifies REST calls by using the Poster browser plug-in for
Firefox. You can use your preferred method to verify REST calls. If
you use a different method for verifying REST calls, ensure that you
can verify all of the calls that are outlined in this lesson.
Procedure
- Start or restart the WebSphere Commerce Test Server.
- Open the Aurora B2B starter store in a web browser, go to: https://localhost/webapp/wcs/stores/servlet/en/aurorab2b.
- Click Sign In/Register. Log in to
the store as a Site Administrator. For example, wcsadmin.
- Sign out the administrator from the store.
- Launch poster for Firefox..
- Go to https://localhost/wcs/resources/store/10801/loginidentity.
Using your log in Id and password, sign in as the Site Administrator
(wcsadmin): The Poster user interface resembles the following screen capture:
Where wcsadmin is the user ID of the Site Administrator, and wcsadmin_pwd is the password of the Site Administrator. - Click POST. A response window displays. Make note of the values for WCToken and WCTrustedToken for later use.
- In the URL field, enter your URL
for the POST to create the data into the XMYRES table. Specify the
value for field1 and field2 in
the body of the Content to Send pane.
For example, https://localhost/wcs/resources/store/10801/my_resource.
- Click the Headers tab within the pane. Add the WCToken and WCTrustedToken values you noted in Step 7.
- Click POST to create a resource
data into the table. If the new data is created successfully, the
corresponding myResourceId is displayed in the
response window.For example:
POST on https://localhost/wcs/resources/store/10801/my_resource Status: 200 OK {"myResourceId":10004}
- If necessary, create more entries in the XMYRES table to test.
- Test the
findByMyResourceId
method. In the URL field, change the URL to: https://localhost/wcs/resources/store/10801/my_resource/10004. - Within the Content to Send pane, remove the values that you specified for field1 and field2.
- Keep the WCToken and WCTrustedToken values you previously added into the Headers pane.
- Click GET. Using the REST service,
The resource data is retrieved through the resource ID number 10004.
The response window with the corresponding information displays.
For example:
GET on https://localhost/wcs/resources/store/10801/my_resource/10004 Status: 200 OK {"myResourceId":10004,"field1":"Timestamp","field2":"2014-10-22T13:09:12.000000000Z"}
- Test the
findMyResourceList
method. In the URL field, change the URL to:https://localhost/wcs/resources/store/10801/my_resource/myResourceListDataBean. - Click GET. The list of resource
data is retrieved by using the REST service. The response window with
the corresponding information displays in the response window.
For example:
GET on https://localhost/wcs/resources/store/10801/my_resource/myResourceListDataBean Status: 200 OK {"myResourceDataBeans": [{"myResourceId":10001,"field1":"Timestamp","field2":"2014-08-12T13:41:07.000000000Z"}, [{"myResourceId":10002,"field1":"Timestamp","field2":"2014-10-21T13:41:07.000000000Z"}, [{"myResourceId":10004,"field1":"Timestamp","field2":"2014-10-22T13:09:12.000000000Z"}]}
- Test the
findSelf
query method. In the URL field, change the URL to: https://localhost/wcs/resources/store/10801/my_resource?q=self. - Click GET. The list of resource
data is retrieved by using the REST service. The response window with
the corresponding information displays in the response window.
For example:
GET on https://localhost/wcs/resources/store/10801/my_resource?q=self Status: 200 OK {"myResourceDataBeans": [{"myResourceId":10001,"field1":"Timestamp","field2":"2014-08-12T13:41:07.000000000Z"}, [{"myResourceId":10002,"field1":"Timestamp","field2":"2014-10-21T13:41:07.000000000Z"}, [{"myResourceId":10004,"field1":"Timestamp","field2":"2014-10-22T13:09:12.000000000Z"}]}
- Open a connection to your database and run SQL statements against your database. Go to: http://localhost/webapp/wcs/admin/servlet/db.jsp.
- In the input box, run the following SQL query:
select * from xmyres;
- The list of resource data is created into the table.
For example:
select * from XMYRES
XMYRES_ID STOREENT_ID MEMBER_ID FIELD1 FIELD2 OPTCOUNTER 10001 10801 -1000 'Timestamp' 2014-08-12 09:41:07.0 NULL 10002 10801 -1000 'Timestamp' 2014-10-21 09:41:07.0 NULL 10004 10801 -1000 'Timestamp' 2014-10-22 09:09:12.0 NULL Note:- If no Coordinated Universal Time relation information is given with a time representation, the time is in local time. It is ambiguous in communicating across different time zones. The Timestamp value you input through Poster is processed by the configuration-based command and data bean mapping framework. All formats are ISO 8601 compliant and everything ends in 'Z' except a SQL Date. A pure date value has no time zone.
- The REST APIs inherit the access control of the underlying commands and data beans. Since the tutorial does not cover setting up sample access control policies for the sample command and data beans, you must to sign in as wcsadmin first. After you sign in, verify the REST service call. For more information about implementing access control, see REST authentication and access control and Implementing access control.
By verifying Poster, you successfully make REST calls to your sample data beans and command. Next, you learn how to customize an existing configuration-based data bean mapping to return more data.