Powered By Blogger

Friday, May 27, 2011

Axis2 in Liferay portlet

Even though Liferay is coming up with the Axis1 jars we can have the system that works in the
portlet with Axis2.

The importan thing is along with the library depedndency jars we need to add the below jars
activation-1.1
antlr-2.7.7
axiom-api-1.2.10
axiom-dom-1.2.10
axiom-impl-1.2.10
axis2-adb-1.5.4
axis2-adb-codegen-1.5.4
axis2-ant-plugin-1.5.4
axis2-clustering-1.5.4
axis2-codegen-1.5.4
axis2-corba-1.5.4
axis2-fastinfoset-1.5.4
axis2-java2wsdl-1.5.4
axis2-jaxbri-1.5.4
axis2-jaxws-1.5.4
axis2-jibx-1.5.4
axis2-json-1.5.4
axis2-kernel-1.5.4
axis2-metadata-1.5.4
axis2-mtompolicy-1.5.4
axis2-saaj-1.5.4
axis2-soapmonitor-servlet-1.5.4
axis2-spring-1.5.4
axis2-transport-http-1.5.4
axis2-transport-local-1.5.4
axis2-xmlbeans-1.5.4
commons-codec-1.3
commons-fileupload-1.2
commons-httpclient-3.1
commons-io-1.4
commons-logging-1.1.1
geronimo-stax-api_1.0_spec-1.0.1
httpcore-4.0
log4j-1.2.15
mail-1.4
neethi-2.0.4
woden-api-1.0M8
woden-impl-dom-1.0M8
wsdl4j-1.6.2
wstx-asl-3.2.9
xmlbeans-2.3.0
XmlSchema-1.4.3


The class will be as below

package com.test;

import java.io.IOException;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import sample.axisversion.ExceptionException;
import sample.axisversion.VersionStub;
import sample.axisversion.VersionStub.GetVersionResponse;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

/**
* Portlet implementation class NewPortlet
*/
public class NewPortlet extends GenericPortlet {

public void init() {
viewJSP = getInitParameter("view-jsp");
}

public void doView(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {

System.out.println("**********View method of NewPortlet ******************8");

VersionStub versionStub = new VersionStub();

GetVersionResponse response;
try {
response = versionStub.getVersion();
System.out.println("**************Return::::"+response.get_return());



} catch (ExceptionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

include(viewJSP, renderRequest, renderResponse);
}

protected void include(
String path, RenderRequest renderRequest,
RenderResponse renderResponse)
throws IOException, PortletException {

PortletRequestDispatcher portletRequestDispatcher =
getPortletContext().getRequestDispatcher(path);

if (portletRequestDispatcher == null) {
_log.error(path + " is not a valid include");
}
else {
portletRequestDispatcher.include(renderRequest, renderResponse);
}
}

protected String viewJSP;

private static Log _log = LogFactoryUtil.getLog(NewPortlet.class);

}

1 comment:

  1. Hi Basu ! very impressive post..thnx.

    my manager had given me two tasks in Liferay portlet:

    1. to connect with mysql database in which the data entered by the user in liferay should persist in db.

    2. to consume a webservice from the portlet.

    fortunately got succeeded in the 1st part.
    but second part still remaining buddy.

    plz help me in this. if u can provide me step by step procedure to consume the wbservice..plz.

    also i am in bangalore only. if u can give me ur no. or catch up with me smtimes, it wud gr8 gesture from ur side.

    thnx and waiting for ur reply...

    ReplyDelete