An Application Programming Interface (API) is a protocol that, when invoked, performs an action or set of actions. You can invoke an API from your own code directly through a Java invocation, or through web services. This chapter provides an overview of several essential Liferay APIs available to you for use in developing your Liferay Portal.

Liferay comes with a host of APIs that provide powerful portal and portlet services. The following table shows you the entities for which services are available:

Portal Services Portlet Services
User Documents and Media Library
Organization Blogs
UserGroup Wikis
Company Assets
Role Social Activity

The ability to call Liferay APIs with a Java method or web service invocation gives you the flexibility to implement client code in Java or any language (even a scripting language such as PHP) that supports web service invocations. The APIs can be called from within portlet or non-portlet code. You can make calls to the APIs locally from within the portal or remotely outside of the portal’s Java virtual machine (JVM).

This chapter covers the following topics:

  • Finding Services
  • Invoking the API Locally
  • Invoking the API Remotely
  • Service Security Layers
  • SOAP Web Services
  • JSON Web Services
  • Service Context
  • Using Message Bus
  • Device Detection
  • Liferay’s Deprecation Policy

You can find Liferay’s services by searching for them in the Javadocs: Below we’ll show you how to search for portal services and portlet services.

Let’s start by finding a portal service.

Finding Portal Services

Liferay’s Javadocs are easy to browse and well-organized. Here’s how you find the Organization services: In your browser, open up the Javadocs: Under...

Read More

Invoking the API Locally

Each service provides a local interface to clients running in the same JVM as Liferay Portal. There are two ways to invoke a service API’s methods: Spring injection: If your application uses Spring...

Read More

Invoking the API Remotely

Remote clients run outside of the portal JVM or on a remote machine, but they can still access Liferay’s service APIs. The main benefit of remotely accessing service APIs is that security checks...

Read More

Service Security Layers

Liferay’s remote services sit behind a layer of security that by default allows only local connections. Access to the remote APIs must be enabled as a separate step in order to call them from a...

Read More

SOAP Web Services

You can access Liferay’s services via Simple Object Access Protocol (SOAP) over HTTP. The packaging protocol is SOAP and the transport protocol is HTTP. As an example, let’s look at the SOAP web...

Read More

JSON Web Services

JSON Web Services let you access portal service methods by exposing them as a JSON HTTP API. Service methods are made easily accessible using HTTP requests, both from JavaScript within the portal...

Read More

Service Context

The ServiceContext class is a parameter class used for passing contextual information for a service. Using a parameter class lets you consolidate many different methods with different sets of...

Read More

Using Message Bus

The Message Bus is a service level API used to exchange messages within Liferay. The Message Bus is a mechanism for sending message payloads to different components in Liferay, providing loose...

Read More

Device Detection

As you know, Internet traffic has risen exponentially over the past decade and shows no sign of stopping. With the latest and greatest devices, mobile Internet access has become the norm and is...

Read More

Liferay’s Deprecation Policy

Methods in Liferay’s APIs are deprecated when they’re no longer called by Liferay internally. Method deprecation occurs during major releases of Liferay. You’ll know when there’s a major release if...

Read More


We’ve covered a lot of ground here. You’ve learned how to use Liferay’s remote APIs, how to enable and disable remote services and access to them, and how to leverage ServiceContext objects in your...

Read More
0 (0 Votes)
Summary Previous