We
can access above URL in web browser so that you can see JSON data and we will
use this URL in Ajax call then we can get the JSON data as response and we
can use this web service URL in any other application or any other clients.

If any web service method needs parameters then we
need to pass parameters to get the data

Example

Get Country by Name

Note:

In the above scenarios we should login as admin into
the portal then only we can see the data. Because it need admin user to access web
services.

If we not login into portal and when we access any
web service URL then we will get following Exception

Accessing
Portal JSON Web Services:

When we access portal JSON web service we need to
override some portal properties using portal-ext.propertis
file.

Generally Portal JSON web services not allowed call
from other client by default, so we need to do some configuration then only other
clients can access

We need provide valid user credential when we call
web service generally we will use admin credentials to call web services.

In the portal when we call web services it will
check host name and authentication credentials, if both are valid then only it
will allow to access JSON web services

We need follow following steps when we access portal
JSON web services.

Step:
1

We need to override following portal properties so
that it will allow calling liferay JSON web services, we need register host
names and we need to tell what are methods allow to public access

The following properties we need to
write in portal-ext.properties file.

json.service.auth.token.hosts.allowed=127.0.0.1,SERVER_IP

json.service.auth.token.enabled=false

jsonws.web.service.public.methods=*

jsonws.servlet.hosts.allowed=127.0.0.1,SERVER_IP

Step:
2

We need to pass valid user credentials as Http
Headers. Generally we use liferay portal admin to access these services