Liferay Portlet using Axis WebService client – Eclipse development


Create Liferay MVC Portlet

Follow the wizard to create Liferay portlet. Remember to check “create portlet class”.

Step 1) Create new Liferay portlet project

Use wizard to create new Liferay Portlet project. Make sure to choose Advanced project configuration… options on the first page and check Axis2:

Wizard creates the following project structure:

Step 2) Edit Java class

Sample Java class:




import javax.portlet.PortletException;

import javax.portlet.RenderRequest;

import javax.portlet.RenderResponse;

import com.liferay.util.bridges.mvc.MVCPortlet;



* Portlet implementation class AccountList


class AccountList extends MVCPortlet {



* @see MVCPortlet#MVCPortlet()


public AccountList() {





void doView(RenderRequest renderRequest, RenderResponse renderResponse)

throws IOException, PortletException {

String[] array = new String[] { “1”, “2”, “3” };

renderRequest.setAttribute(“myTable”, array);

super.doView(renderRequest, renderResponse);



Step 3) Edit JSP and configuration files

Add JSTL2 taglib

Add the following definitions to your JSP file

<%@ taglib uri=”; prefix=”c” %>
<%@ taglib uri=”; prefix=”fmt” %>
<%@ taglib uri=”; prefix=”fn” %>
<%@ taglib uri=”; prefix=”sql” %>
<%@ taglib uri=”; prefix=”x” %>

Edit web.xml

Add the following references to \liferay-portal-6.0.6\tomcat-6.0.29\webapps\ROOT\WEB-INF\web.xml file. Check whether those references do not exist yet.




This reference must be included in local file in the project.


Add web service to your portlet (method 1)

Step 1) prepare and validate WSDL

I use SOAP-UI to validate WSDL. If SOAP-UI is able to generate project based on WSDL, hence the file and surrounding schemas are OK. Once validated OK, copy WSDL and surrounding XSD files to your project, e.g. into newly created \wsclient folder.

Step 2) generate client stub

Right-click on WSDL and select Web Services > Generate Client

Step 3) move generated sources

Move generated sources from /src to /docroot/WEB-INF/src directory

Step 4) Create and move JAR for XMLBeans

Axis2 is creating XMLBeans in \resources directory. In order to make them available to the run-time, do the following:

  1. Zip schemaorg_apache_xmlbeans
  2. Rename Zip to Jar
  3. Move schemaorg_apache_xmlbeans.jar to \docroot\WEB-INF\lib\ directory

After deployment, file will be available to the run-time environment.

Step 5) Call web service

Service call is managed by the following code in the portlet class:

xxxx.ICSOBPortStub stub = new xxxx.ICSOBPortStub();


try {


// initialize data objects

xxxx.LogonRequestDocument logonRequestDocument = LogonRequestDocument.Factory.newInstance();

xxxx.LogonResponseDocument logonResponseDocument = null;

xxxx.LogonRequestDocument.LogonRequest logonRequest = logonRequestDocument.addNewLogonRequest();


// set request parameters




    // create request document



// execute service

    logonResponseDocument = stub.logon(logonRequestDocument);


    System.out.println(“Response : “ + logonResponseDocument.getLogonResponse());


} catch (java.lang.Exception e){

    System.out.println(“exception occured: “ + e.toString());