Issue
- While accessing http://localhost:8080/api/jsonws as an unauthenticated (Guest) user and selecting the context path, an "Access denied" error is thrown.
-
For example, when creating a simple Service Builder Module and keeping it default as it will create FOO.
-
Write a simple
getData()method insideFooServiceImpl, build this module and deploy it. -
After deploying, open http://localhost:8080/api/jsonws as an unauthenticated user, select context name as foo ->Click on getData ->Click on Invoke. The below error is thrown;
"Access denied to com.liferay.ws.service.FooService#getData"
-
Environment
- Liferay DXP 7.1
Resolution
- The above error can be resolved by following the below steps:
1) Navigate to Control Panel> Configuration>Service Access Policy
2) Click on "+" icon to add a new policy,
3) Check the "enabled" and "default" checkbox.
4) Provide any name and title along with Class Name and Method name which needs to be exposed and save it. Refer the below image.
- The unauthenticated users will now be able to access the newly created web services.