Liferay Portal Client Example

In the past and recently I got to be among two systems, one of which Liferay. The system in the middle, was Mule ESB, the mediator between the two systems. The first of the two systems published a series of messages on a JMS queue, these messages were consumed by ESB Mule and after a series of elaborations shipped to the second system (Liferay).

At that time, Liferay had just SOAP services (services rest, would come later), based on the old framework Apache Axis 1.4 and style rpc / encoded. The SOAP component of Mule ESB based on Apache CXF is not compatible with the model rpc / encoded. The first solution was to create the client (to be done later use in Mule ESB) for services of Liferay, starting from the WSDL of the service with which it was necessary to communicate, many of you will know how boring it can be this activity.

In Liferay someone to "good heart" had decided to make available the Liferay Portal Client, this has made the happiness of myself first and foremost and secundis halved the time development of the flow of Mule ESB. Later I realized that the Liferay Portal Client is known by a handful of insiders around, even Liferay itself does not mention the existence in their own documentation SOAP Web Services, is usually discussed the process of creating the client via the WSDL.

Last week I found myself in a similar situation where the Liferay Portal Client has been useful in an integration, by halving the time of development. I made the decision to publish on my GitHub repository a complete example of use of the Liferay Portal Client. The sample project liferay-portal-client-example, based on Maven that performs the following tasks:

  • Performs login on Liferay;
  • Retrieves the CompanyID based on the virtualhost;
  • Retrieve UserId of the user to ScreenName and CompanyID;
  • Retrieves the GroupId of the site Guest;
  • Performs the upload of a document on the Document Library site Guest.

Following an extract of the logs that show the execution of the main class UploadDocumentOnDL. The services used are:

  • Portal_UserService
  • Portal_CompanyService
  • Portal_GroupService
  • Portlet_DL_DLAppService

WSDL documents of all the services exposed by the portal can be reached at http://${HOST|FQDN|IP}:${TCP/IP PORT}/api/axis

[00:18:15,816 INFO UploadDocumentOnDL]: Try lookup User Service by End Point: http://will:will@localhost:8080/api/secure/axis/Portal_UserService...
[00:18:16,176 INFO UploadDocumentOnDL]: Try lookup Company Service by End Point: http://will:will@localhost:8080/api/secure/axis/Portal_CompanyService...
[00:18:16,343 INFO UploadDocumentOnDL]: Get UserID...
[00:18:16,378 INFO UploadDocumentOnDL]: UserId for user named will is 11801
[00:18:16,378 INFO UploadDocumentOnDL]: Try lookup Group Service by End Point: http://will:will@localhost:8080/api/secure/axis/Portal_GroupService...
[00:18:16,441 INFO UploadDocumentOnDL]: Found the group Guest (GroupId: 19) to publish the document
[00:18:16,441 INFO UploadDocumentOnDL]: Try lookup DL App Service by End Point: http://will:will@localhost:8080/api/secure/axis/Portlet_DL_DLAppService...
[00:18:16,922 INFO UploadDocumentOnDL]: The file BenchmarkingSugarOnSolaris-SugarCon2009.pdf has been correctly added to liferay
[00:18:16,922 INFO UploadDocumentOnDL]: File Id:13101
[00:18:16,922 INFO UploadDocumentOnDL]: File Size: 735142
[00:18:16,922 INFO UploadDocumentOnDL]: File Version: 1.0

The advantage of using the Liferay Portal Client is more than obvious and hopefully always someone "good heart" to do the same for RESTful services.

Antonio Musarra

I began my journey into the world of computing from an Olivetti M24 PC (http://it.wikipedia.org/wiki/Olivetti_M24) bought by my father for his work. Day after day, quickly taking control until … Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.

You may also like...