Testing JSON Web Services in Liferay

This article documents the new implementation of JavaScript Object Notation (JSON) web services in Liferay Portal 6.1.x to test API methods. The only limitation is that to test any methods they must go through JSON.

A database other than Hypersonic will be required for API testing as Hypersonic is for testing and will not produce accurate results.

Resolution

To start testing:

  1. Start up the Liferay Portal and login as the administrator
  2. Once logged in, navigate to [YOUR_SITE]/api/jsonws (e.g. http://localhost:8080/api/jsonws)
  3. On the left is a list of Liferay APIs. Click on one.
    1. From here, the path, parameters, return type, and exception information for that API are displayed. On the bottom, users can run a search that will parse through the existing data in the database to retrieve that string.
  4. From the main API testing page—[YOUR_SITE]/api/jsonws—click on get-user-by-id (e.g. http://localhost:8080/api/jsonws?signature=/user/get-user-by-id-1-userId).
  5. In the bottom userId form, type in 10158, which is a default user upon installation of Liferay.
  6. Click Invoke

The result should be populated information in the Execute section.

agreedToTermsOfUse": true, "comments": "", "companyId": 10154, "contactId": 10159, "createDate": 1383249122000, "defaultUser": true, "emailAddress": "", "emailAddressVerified": false, "facebookId": 0, "failedLoginAttempts": 0, "firstName": "", "graceLoginCount": 0, "greeting": "Welcome!", "jobTitle": "", "languageId": null, "lastFailedLoginDate": null, "lastLoginDate": null, "lastLoginIP": "", "lastName": "", "lockout": false, "lockoutDate": null "loginDate": 1383249122000, "loginIP": "", "middleName": "", "modifiedDate": 1383249122000, "openId": "", "portraitId": 0, "reminderQueryAnswer": "", "reminderQueryQuestion": "", "screenName": "10158", "status": 0, "timeZoneId": null, "userId": 10158, "uuid": "b6e14dd2-93a5-4ed2-b8d6-f294e6e79724" }

Additional Information

Liferay Portal 6.2 User Guide: Remotely Accessing Liferay Services

这篇文章有帮助吗?
0 人中有 0 人觉得有帮助