« Back to Web Services

Creating Liferay 6 plugin web service

Today I tried to create a service in a plugin portlet of liferay. Since this is not very straight forward, it took me the whole day to get my simple service running. As a matter of fact, I decided to publish this on the web.

I used Liferay6.0.5 source and plugin sdk, along with eclipse 3.6, with WTP and Liferay IDE 1.0.1. The base platform was Java1.6.0_21 and MySQL5.1.46, both running on openSuse11.3. The deployment server was tomcat6.0.26.

Step 1: Setup liferay source project and tomcat

  1. Unzip the liferay source in your eclipse workspace. In eclipse, create a new project with the name liferay-portal-src-6.0.5. Eclipse will automatically detect the project type and configure it accordingly.

  2. Open the app.server.properties and edit the app.server.parent.dir to point to the folder containing the tomcat installation. Note that this is the parent folder of CATALINA_HOME. For me it was: app.server.parent.dir=/home/swoosh/installations

  3. Un-comment: app.server.type=tomcat

  4. Scroll down and change the app.server.tomcat.dir, so that it points to the CATALINA_HOME. For me it was: app.server.tomcat.dir=${app.server.parent.dir}/liferay-tomcat-6.0.26

  5. Save and close the app.server.properties

  6. Create a DB schema and user using any tool (I used MySQL Administrator)

  7. Open the portal.properties and comment out the HSQL (Hypersonic) DB settings.

  8. Un-comment the MySQL DB settings and change the host, schema name, username and password. For me the settings were:
    jdbc.default.driverClassName=com.mysql.jdbc.Driver
    jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
    jdbc.default.username=liferay
    jdbc.default.password=test

  9. Save and close the portal.properties file.

  10. Now open the ant view in eclipse and drag liferay-portal-src-6.0.5/portal-web/build.xml and liferay-portal-src-6.0.5/build.xml file to the ant view. Wait for some time as ant loads the set of build files.

  11. Run the build-themes task under portal-web (from liferay-portal-src-6.0.5/portal-web/build.xml). Make sure that you get Build Successful message everytime you fire an ant task. (There is a bug in liferay's builder due to which it doesn't create the themes when you compile the source. If you directly deploy the source, you wont be able to access the home page).

  12. Now run the compile task under portal (from liferay-portal-src-6.0.5/build.xml).

  13. Then run the deploy task under the same file. Watch the log to verify that ant is copying the files to the right folder. If not, then double check the settings specified in the app.server.properties file.

  14. Now you have tomcat bundled up with the liferay portal. To start it you need to set up the runtime in eclipse. Go to Window->Preferences->Server->Runtime Environments. Click Add. Select the srever type as Liferay v6.0 (Tomcat 6). Click next. Give a name to your runtime - Liferay v6 (Tomcat 6). Browse and select the tomcat folder that you specified in app.server.properties' app.server.tomcat.dir property. Select runtime as java 1.6 and click Finish.

  15. If you don't have a server project in your workspace, then create a new one. Right click on the server project and Create a new server. Select the server type as Liferay v6.0 (Tomcat 6) and runtime as Liferay v6 (Tomcat 6). Server's host name should be localhost. Click next and click Finish.

  16. Now the server should appear under your server view (Add the view from Window->Show View->Servers)

  17. Double click on the server and change the Timeouts to 300 seconds. This will give enough time to the server to create and populate the DB schema for the first time.

  18. Right click on the server and select start.

  19. The liferay server should start. For the first time, it will create all the tables and populate them with the seed data.

  20. Once you get the server started message, open the web browser and open the http://localhost:8080. You should get the liferay's default home page. Enter test@liferay.com as email address and test as password.

  21. If you are not able to see the liferay's page even though the source was compiled and deployed successfully, then please check your app.server.properties file.

Step 2: Setup plugin SDK.

  1. Download and unzip the plugins sdk.

  2. Open the liferay-plugins-sdk-6.0.5/build.properties file and change the server settings:
    app.server.type=tomcat app.server.dir=/home/swoosh/installations/liferay-tomcat-6.0.26 app.server.deploy.dir=${app.server.dir}/webapps app.server.lib.global.dir=${app.server.dir}/lib/ext app.server.portal.dir=${app.server.dir}/webapps/ROOT

  3. Go to Window->Preferences->Liferay->Installed SDKs.

  4. Click on Add. In the pop-up window browse to the unzipped sdk folder and click Ok.

Step 3: Create the service project

  1. Now create a new Liferay plug-in project. Enter the details as in the screenshot below:

  2. Click Next and select Dynamic Web module version 2.5 and Default configuration for Liferay v6.0 (Tomcat 6).

  3. Click Finish and Click Yes on the Switch Perspective dialog box.

  4. A new TestPlugin-Portlet Project will appear in the navigator.

  5. Now right click on the plugin project and select New->Liferay Service.

  6. Enter the detail as in the screenshot below:

  7. You can enter a different package and Namespace. In that case you will have to follow the next steps accordingly.

  8. Click Finish. The service.xml file will be created and will be opened in the service editor.

  9. The service.xml is similar to the service definition files in the ext environment of older liferay versions. Here we can define as many entities along with their functions.

  10. We will create an Employee entity with id (long) and name (String) attributes. The service definition looks like:

  11. Save the service.xml file.

  12. Drag the TestPlugin-portlet/build.xml to the Ant view.

  13. In the ant view, expand the TestPlugin-portlet and run the build-service task.

  14. If the build fails, please check if you have followed the point number 2 in Step 2. On successful build, the ant task creates the files related to Employee entity.

  15. Refresh your project (F5) to see the files.

  16. Right click on the project go to Properties->Java Build Path->Source tab. Add the TestPlugin-portlet/docroot/WEB-INF/service and TestPlugin-portlet/docroot/WEB-INF/src folders, and click Ok.

  17. Implement the service by editing com.liferay.test.service.impl.EmployeeLocalServiceImpl. Add the implementations for CRUD and finder methods. They look like the following listing:
    public Employee create(Employee model) throws SystemException{
      long id = CounterLocalServiceUtil.increment(Employee.class.getName());
      model.setId(id);
      Employee newModel = EmployeeUtil.create(model.getId());

      newModel.setName(model.getName());
      EmployeeUtil.update(newModel, true);
      return newModel;
    }

    public Employee update(Employee model) throws NoSuchEmployeeException, SystemException{
      Employee newModel = EmployeeUtil.findByPrimaryKey(model.getId());

      newModel.setName(model.getName());

      EmployeeUtil.update(newModel, true);

      return newModel;
    }

    public List<Employee>
    findByName(String name) throws SystemException{
      return EmployeeUtil.findByName(name);
    }

    public Employee remove(long id) throws NoSuchEmployeeException, SystemException{
      return EmployeeUtil.remove(id);
    }

  18. Run the TestPlugin-portlet/build-service task and make sure that build is successful.

  19. Similarly edit the com.liferay.test.service.impl.EmployeeServiceImpl Add the CRUD and finder methods as listed below:
    public Employee create(Employee model) throws SystemException{
      return EmployeeLocalServiceUtil.create(model);
    }

    public Employee update(Employee model) throws NoSuchEmployeeException, SystemException{
      return EmployeeLocalServiceUtil.update(model);
    }

    public List<Employee> findByName(String name) throws SystemException{
      return EmployeeLocalServiceUtil.findByName(name);
    }

    public Employee remove(long id) throws NoSuchEmployeeException, SystemException{
      return EmployeeLocalServiceUtil.remove(id);
    }

  20. Run the TestPlugin-portlet/build-service task again and make sure that build is successful.

  21. There is a bug in liferay's service builder due to which it doesn't generate the ServiceSoap class correctly. It is not able convert the parameters to their corresponding soap type. See http://issues.liferay.com/browse/LPS-12629 for details. To get around this issue open the EmployeeServiceSoap and change the generated create and update methods as:

     
    publicstatic com.liferay.test.model.EmployeeSoap create(
       com.liferay.test.model.EmployeeSoap model) throws RemoteException {
     try {
      com.liferay.test.model.Employee returnValue = EmployeeServiceUtil.create(com.liferay.test.model.impl.EmployeeModelImpl.toModel(model));
     
      return com.liferay.test.model.EmployeeSoap.toSoapModel(returnValue);
      }
      catch (Exception e) {
      _log.error(e, e);
     
      throw new RemoteException(e.getMessage());
      }
    }
     
    publicstatic com.liferay.test.model.EmployeeSoap update(
       com.liferay.test.model.EmployeeSoap model) throws RemoteException {
     try {
      com.liferay.test.model.Employee returnValue = EmployeeServiceUtil.update(com.liferay.test.model.impl.EmployeeModelImpl.toModel(model));
     
      return com.liferay.test.model.EmployeeSoap.toSoapModel(returnValue);
      }
      catch (Exception e) {
      _log.error(e, e);
     
      thrownew RemoteException(e.getMessage());
      }
    }

  22.  Now run the TestPlugin-Portlet/build-wsdd task to generate the webservices.

  23. Once this is complete, start the server if not already started.
  24. Then run TestPlugin-Portlet/compile and TestPlugin-Portlet/deploy.
  25. Check the logs for "1 portlet for TestPlugin-portlet is available for use" message.
  26. If that appears, open the http://localhost:8080 in your browser.
  27. Login as test@liferay.com and password test.
  28. Go to Add -> More->Samples. Add the TestPlugin to you page. Make sure that the default page for the plugin appears. This confirms that the plugin was deployed properly.
  29. Now open http://127.0.0.1:8080/TestPlugin-portlet/axis/Plugin_Test_EmployeeService?wsdl in your browser and confirm that the wsdl opens up.
  30. This completes the plugin service creation.

Step 4: Create Web service client

  1. Now we need to test our webservice. For that we need to have another tomcat runtime as our Liferay tomcat 6 runtime eclipse plugin doesn't support building webservices. Also we need to make sure that the tomcat runtime and liferay runtime run on different ports. I used the ports 9005, 9080 and 9009 for my tomcat runtime.

  2. In eclipse go to New->Webservice Client and enter the details as in the screenshot below:

  3. Click Next on this and next screen. Then click on "Start server" to start the tomcat runtime. Then click Finish.

  4. Select all the methods and click Finish

  5. Eclipse will then deploy the client and open up a screen to test your webservice.

  6. Click on the methods to test them.

  7. We will test create method first. We will provide the primaryKey=0, name=Liferay and id=0 and click invoke.

  8. In the results section we can see that the employee entity has been created with the id=1.

  9. Now invoke findByName and provide name=Liferay. The result will show the reference of the entity object returned by the webservice.

That completes the tutorial. The complete plugin and the webservice client can be downloaded from the attachments of this post. Hope that was helpful. Do write your comments.


2 Attachments
65959 Views
Average (11 Votes)
The average rating is 4.54545454545455 stars out of 5.
Comments
Threaded Replies Author Date
Nice article. Thanks! Juan Fernández September 14, 2010 1:28 AM
Thanks for the feedback :) Kapil Dev Verma September 14, 2010 2:24 AM
Some picture of this article can't display,I... XinYang Zhang September 14, 2010 2:29 AM
I have updated the article, hope you can see... Kapil Dev Verma September 14, 2010 4:25 AM
Please, I need your help:) Everything compiles,... Marius Marius September 14, 2010 5:50 AM
If everything goes fine, then you should get... Kapil Dev Verma September 14, 2010 9:50 AM
Hi Kapil Thanks for the excellent article. I... Liferay Developer September 17, 2010 8:41 AM
Hi.. Please provide me the zip of your plugin... Kapil Dev Verma September 19, 2010 11:56 AM
Kapil, what is the best way to send you the... Liferay Developer September 23, 2010 12:23 PM
You can mail me that at kapildverma@gmail.com Kapil Dev Verma September 26, 2010 10:15 PM
In this tutorial you advice to edit... Andrius Kurtinaitis September 14, 2010 6:06 AM
Thanks for the suggestion :) Kapil Dev Verma September 14, 2010 9:48 AM
Hi Kapil, Really very nice description to... sasi Kanth September 16, 2010 11:12 PM
Thanks Sasi for the feedback! Kapil Dev Verma September 17, 2010 1:37 AM
Very Nice Article. Thanks!! Harish Kumar September 27, 2010 9:34 PM
I need some help. Everything compiles, the wsdd... Andreea Tabacariu October 27, 2010 2:53 AM
Can you try running the samples attached with... Kapil Dev Verma November 10, 2010 11:59 PM
anybody know this error, help me.... DO Hung Thuan November 14, 2010 11:55 PM
Is there a way to expose REST based services... Seshendra Nalla November 24, 2010 8:29 AM
Hi there, at the end of your tutorial when I... Jack Bauer November 25, 2010 11:55 AM
Ok so I noticed what I was doing wrong, stupid... Jack Bauer November 26, 2010 10:17 AM
Result exception: java.rmi.RemoteException:... Sreeraj AV December 26, 2010 11:37 PM
@Raju - The issue seems to somewhere in... Kapil Dev Verma December 28, 2010 9:22 PM
Very nice article. Thanks!!! Dien NH January 20, 2011 6:38 PM
When I was executing the build-service task ant... Luca Andreatta January 25, 2011 3:09 AM
Hi Kapil, I have a requirement, where instead... Venkat S February 7, 2011 2:27 PM
Hi Venkat, From the stacktrace, we can see... Kapil Dev Verma February 9, 2011 9:54 PM
First thank you for a great guide, works great... Andrew Tillinghast February 28, 2011 11:52 AM
Hi Andrew, Thanks for your comments. I am not... Kapil Dev Verma March 4, 2011 10:24 AM
Nice article.Thank Kapil! Nguyen Trung Kien March 11, 2011 7:23 AM
Hi Kapil, I want add new method in existing... Nguyen Trung Kien March 12, 2011 5:55 PM
Hi Nguyen, You might have to create a new... Kapil Dev Verma March 21, 2011 12:20 AM
Nice article. Thank you Tom Mahy August 22, 2011 5:31 AM
Concerning Error:... Martin Schwietzke September 9, 2011 3:46 PM
Sorry, it was a mistake. Removing axis.jar is... Martin Schwietzke September 12, 2011 5:38 AM
Venkat S, dont forget to run a new tomcat... Tamás Barabás November 28, 2011 3:53 AM
Hi Kapli, Nice Article But i have an... Raghu teja December 14, 2011 9:58 PM
I'm getting exception:... Shantanu Puranik February 1, 2012 1:13 AM
This worked perfect on 6.0.6 but on 6.1 i cant... Tom Mahy February 17, 2012 6:03 AM
You can find service under /api/axis on liferay... Sy Do March 5, 2012 8:10 PM
in step 3 -> 29 i cannot seem to get the WSDL... Patrick Momin March 15, 2012 7:50 AM
I found the Solution by comparing the entries... Patrick Momin March 16, 2012 2:37 AM
Hi, I'm experiencing a problem since few days.... Giuseppe Pantaleo June 19, 2012 2:17 AM
I have same problem. Can you tell me solution? ... Karel Teniska July 12, 2012 2:53 AM
For all , problem is in implement of... Karel Teniska July 14, 2012 2:36 AM
Try this URL... Onkar Sutar February 5, 2013 1:35 AM
Thanks , Its was very helpful. Atif Hussain January 7, 2013 4:08 AM
Nice..For Beginners..Its really nice... sheela mk February 18, 2013 10:57 PM
Nice Article kapil Thanks for sharing...:) jaid shaik May 15, 2013 2:29 AM
Hi Kapil, I have take your sample portlet and... Abdulbasit Shaikh June 7, 2013 4:54 AM
Hi Kapil, Thanks for such a nice doucment.I... Abdulbasit Shaikh June 11, 2013 1:55 AM
I am using Liferay 6.1.1 I need some help.... Syed Mujeeb March 21, 2014 1:18 PM

Nice article. Thanks!
Posted on 9/14/10 1:28 AM.
Thanks for the feedback emoticon
Posted on 9/14/10 2:24 AM in reply to Juan Fernández.
Some picture of this article can't display,I can't see them.Could you fix it
Posted on 9/14/10 2:29 AM.
I have updated the article, hope you can see the images now. Please do a ctrl+F5.
Posted on 9/14/10 4:25 AM in reply to XinYang Zhang.
Please, I need your helpemoticon
Everything compiles, deploys etc. but I am stuck at this point: http://127.0.0.1:8080/TestPlugin-portlet/axis/Plugin_Test_EmployeeService?wsd I get axis error because "Could not generate WSDL"
of cource and there: http://127.0.0.1:8080/tunnel-web/axis I don't see my plugin.
Posted on 9/14/10 5:50 AM in reply to Kapil Dev Verma.
In this tutorial you advice to edit portal.properties file. This is oficially not recommended. This file does not even exist in a zipped bundle. Wouldn't it be better to change this filename to portal-ext.properties?
Posted on 9/14/10 6:06 AM.
Thanks for the suggestion emoticon
Posted on 9/14/10 9:48 AM in reply to Andrius Kurtinaitis.
If everything goes fine, then you should get docroot/WEB-INF/server-config.wsdd file generated. Verify if it is getting generated. Also, it would be helpful if you attach your plugin project.
Posted on 9/14/10 9:50 AM in reply to Marius Marius.
Hi Kapil,

Really very nice description to generate service and web serivces in a portlet.

Thank you.
Posted on 9/16/10 11:12 PM.
Thanks Sasi for the feedback!
Posted on 9/17/10 1:37 AM in reply to sasi Kanth.
Hi Kapil

Thanks for the excellent article.
I am having the same problem as Marius. There is an error when I try to generate the wsdl and I checked for the server-config.wsdd and was not able to find it.
Posted on 9/17/10 8:41 AM in reply to Kapil Dev Verma.
Hi.. Please provide me the zip of your plugin project. Thanks!
Posted on 9/19/10 11:56 AM in reply to Liferay Developer.
Kapil,
what is the best way to send you the zip?
Thanks..
Posted on 9/23/10 12:23 PM in reply to Kapil Dev Verma.
You can mail me that at kapildverma@gmail.com
Posted on 9/26/10 10:15 PM in reply to Liferay Developer.
Very Nice Article. Thanks!!
Posted on 9/27/10 9:34 PM.
I need some help. Everything compiles, the wsdd is created, the deploy works with no error, the portlet page loads but when I try to see the wsdl: http://127.0.0.1:8080/TestPlugin-portlet/axis/Plugin_Test_EmployeeService?wsd I am redirected to the portal home page and my service does not appear in http://127.0.0.1:8080/tunnel-web/axis
Posted on 10/27/10 2:53 AM.
Can you try running the samples attached with the post? If you still face the problem, please feel free to mail me your plugin.
Posted on 11/10/10 11:59 PM in reply to Andreea Tabacariu.
anybody know this error, help me.
http://www.liferay.com/community/forums/-/message_boards/message/6414062
Posted on 11/14/10 11:55 PM.
Is there a way to expose REST based services instead of SOAP using Liferay Service builder?
Posted on 11/24/10 8:29 AM.
Hi there, at the end of your tutorial when I try to test by adding a Webservice Client I get the following error:

"The Apache Axis Web service runtime in Tomcat v6.0 Server does not support the client project TestPlugin-portlet."

I set it up exactly as you have it laid out in the picture as well so hopefully someone knows how to solve this problem because I find nothing when googling.
Posted on 11/25/10 11:55 AM.
Ok so I noticed what I was doing wrong, stupid mistake trying to setup the WebService Client to point to the TestPlugin instead of the WebServiceProject attached.

I'll just list some problems and solutions I had here for anyone else that runs into the same stuff I did. You need to import that WebServiceProject attached and do the WebServices Client on that.

After installing another version of Tomcat on your system you have to go into the tomcat/conf/server.xml to modify the ports like Kapil mentioned.

I also had to copy all the jars inside the WEB-INF/lib folder of WebServiceProject into the alternate Tomcat/lib folder.
Posted on 11/26/10 10:17 AM in reply to Clayton Jarczewski.
Result
exception: java.rmi.RemoteException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.SQLGrammarException: could not load an entity: [com.liferay.test.model.impl.EmployeeImpl#2]


how can i solve this issue?
Posted on 12/26/10 11:37 PM.
@Raju - The issue seems to somewhere in database. Are you sure that the tables are created as required? See portlet-hbm.xml and portlet-orm.xml in /TestPlugin-portlet/docroot/WEB-INF/classes/META-INF/. Use sql files in /TestPlugin-portlet/docroot/WEB-INF/sql/ to create the tables.
Posted on 12/28/10 9:22 PM in reply to Raju OO7.
Very nice article. Thanks!!!
Posted on 1/20/11 6:38 PM.
When I was executing the build-service task ant was waiting in the java-compile ant task. I setted fork to "no" and all goes ok. Is there any controindication?
Posted on 1/25/11 3:09 AM.
Hi Kapil,

I have a requirement, where instead of accessing db i want a webservice which does action on cache, so i tried to follow the same steps except one change,
(ie)
<entity name="Employee" local-service="true" remote-service="true"></entity>

I was able to deploy, but i get the below classcastexception, can u please help,

"AXIS error
Sorry, something seems to have gone wrong... here are the details:

Fault - ; nested exception is:
org.apache.axis.ConfigurationException: java.lang.ClassCastException: org.apache.axis.handlers.http.URLMapper cannot be cast to org.apache.axis.Handler
java.lang.ClassCastException: org.apache.axis.handlers.http.URLMapper cannot be cast to org.apache.axis.Handler
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.makeNewInstance(WSDDDeployabl­eItem.java:302)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployable­Item.java:274)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableIte­m.java:260)
at org.apache.axis.deployment.wsdd.WSDDDeployment.getHandler(WSDDDeployment.java:39­4)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployable­Item.java:276)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableIte­m.java:260)
at org.apache.axis.deployment.wsdd.WSDDChain.makeNewInstance(WSDDChain.java:125)
at­ org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployable­Item.java:274)...."
Posted on 2/7/11 2:27 PM in reply to Luca Andreatta.
Hi Venkat,

From the stacktrace, we can see that the makeNewInstance method in WSDDDeployableItem.java is expecting org.apache.axis.Handler, however, org.apache.axis.handlers.http.URLMapper is being passed.

It seems to be some configuration problem or it can even be version miss match. This has nothing to do with accessing DB or calling action on cache. The error is purely on axis side.

Please send me your project zip at kapildverma@gmail.com so that i can debug it.

Regards,
Kapil
Posted on 2/9/11 9:54 PM in reply to Venkat S.
First thank you for a great guide, works great for 6.0.5

Now I have a Axis security question:

Is there any way to make /TestPlugin-Portlet/axis available to external IPs and still leave /tunnel-web/axis local IP only?

I know I can set axis.servlet.hosts.allowed= and leave the value blank to open the axis service to the world, but that opens the liferay wsdd as well, I just want to expose my custom SOAP services.

It looks to me that I could change the <init-param> values in my web.xml but would be over written every time I deploy.
<init-param>
<param-name>portal_property_prefix</param-name>
<param-value>axis.servlet.</param-value>
</init-param>


-Andrew
Posted on 2/28/11 11:52 AM in reply to Kapil Dev Verma.
Hi Andrew,

Thanks for your comments. I am not an expert with axis. However, you can have a look at apache webserver's mod_proxy to achieve this....

http://httpd.apache.org/docs/trunk/mod/mod_proxy.html

Regards,
Kapil
Posted on 3/4/11 10:24 AM in reply to Andrew Tillinghast.
Nice article.Thank Kapil!
Posted on 3/11/11 7:23 AM.
Hi Kapil,
I want add new method in existing Liferay webservice as add new addGroupEXT to GroupServiceSOAP. What should I do?
I'm using Liferay CE 6.05.
Thanks.
Posted on 3/12/11 5:55 PM.
Hi Nguyen,

You might have to create a new webservice for your extended class. The problem is that the webservice definition for GroupServiceSoap is embedded in liferay code and it can't be modified (without changing liferay code). So you will have to create a new webservice, with your custom addGroupEXT() method, which internally uses the liferay APIs to accomplish the tasks.

You can create your new class something like GroupEXTServiceImpl, import com.liferay.portal.service.GroupServiceUtil and write a method addGroupEXT() in it. From that method, you can call the GroupServiceUtil.addGroup().

Then you can expose your new class as webservice.

You can also try this by changing the plugin project attached with this post. It will be a lot easier if you are using Liferay's Eclipse plugin.

--
Kapil
Posted on 3/21/11 12:20 AM in reply to Nguyen Trung Kien.
Nice article. Thank you
Posted on 8/22/11 5:31 AM.
Concerning Error: "org.apache.axis.handlers.http.URLMapper cannot be cast to org.apache.axis.Handler"

There are some classloading issues. axis.jar is deployed in ROOT.war and in your Plugin WAR.

Solution: Remove the axis.jar in your Plugin WAR (WEB-INF/lib). It works fine for me.
Posted on 9/9/11 3:46 PM in reply to Tom Mahy.
Sorry, it was a mistake. Removing axis.jar is not jet the solution. One ERROR has been gone, but NoClassDefError occurs on other location.

Does anybody have a solution for the Problem?
Posted on 9/12/11 5:38 AM in reply to Martin Schwietzke.
Venkat S,

dont forget to run a new tomcat server, so you have the liferay's tomcat boundled, and a clear tomcat for the client
Posted on 11/28/11 3:53 AM.
Hi Kapli,

Nice Article

But i have an issue with this ,when i am trying to bulid client (as per you article URL)as below its working fine ,methods are invoking and getting results

http://127.0.0.1:8080/TestPlugin-portlet/axis/Plugin_Test_EmployeeService?wsdl

Bu­t when i am trying to bulit webservice client as below URL ,

http://127.0.0.1:8080/TestPlugin-portlet/secure/axis/Plugin_Test_EmployeeService­?wsdl

methods are invoked but when iam trying to get results shows as
RE:404 unauthroized

Is Anything wrong in the URL???
Posted on 12/14/11 9:58 PM in reply to Tamás Barabás.
I'm getting exception: java.rmi.RemoteException: BeanLocator has not been set
Posted on 2/1/12 1:13 AM in reply to Raghu teja.
This worked perfect on 6.0.6 but on 6.1 i cant find the service under /tunnel-web/axis
Has anything changed ?
Posted on 2/17/12 6:03 AM in reply to Shantanu Puranik.
You can find service under /api/axis on liferay 6.1
Posted on 3/5/12 8:10 PM in reply to Tom Mahy.
in step 3 -> 29 i cannot seem to get the WSDL to show i get following error:

HTTP Status 404 - /TestPlugin-portlet/axis/Plugin_Test_EmployeeService

type Status report

message /TestPlugin-portlet/axis/Plugin_Test_EmployeeService

description The requested resource (/TestPlugin-portlet/axis/Plugin_Test_EmployeeService) is not available.
Apache Tomcat/7.0.23
Posted on 3/15/12 7:50 AM.
I found the Solution by comparing the entries in the corresponding web.xml files:

in liferay 6.1 the url to call is "/TestPlugin-portlet/api/axis" instead of "/TestPlugin-portlet/axis"

I hope this saved some people's time.
Posted on 3/16/12 2:37 AM in reply to Patrick Momin.
Hi, I'm experiencing a problem since few days.
My development environment is the following: I'm using Liferay6.1.0 CE GA1 source and plugin sdk, along with Eclipse Indigo Service Release 2, with WTP and Liferay IDE 1.5.2. The base platform is Java1.6.0_32 and the deployment server is Tomcat 7.0.23 (the one bundled with Liferay).
While executing the step 3 -22 (running TestPlugin-Portlet/build-wsdd) I'm getting the following error:
build-wsdd:
Loading jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/­portal-impl.jar!/system.properties
19-giu-2012 9.05.48 com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Global lib directory /D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/lib/ext/
19-giu-2012 9.05.48 com.liferay.portal.kernel.log.Jdk14LogImpl info
INFO: Portal lib directory /D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/
09:05:48,470 INFO [EasyConf:122] Refreshed the configuration of all components
09:05:48,770 INFO [ConfigurationLoader:56] Properties for jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/­portal-impl.jar!/portal loaded from [jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib­/portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties,­ file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/classes/­portal-ext.properties, jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/­portal-impl.jar!/portal.properties]
Loading jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/­portal-impl.jar!/portal.properties
Loading file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/classes/­portal-ext.properties
Loading jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib/­portal-impl.jar!/com/liferay/portal/tools/dependencies/portal-tools.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/WEB-INF/lib­/util-java.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/liferay-plugins-sdk-6.1.0-ce-ga1/portlets/TestPlugin-portlet/docro­ot/WEB-INF/lib/util-java.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Java2WSDL com.liferay.test.service.http.EmployeeServiceSoap
09:05:52,085 WARN [Types:1704] The class com.liferay.test.model.Employee does not contain a default constructor, which is a requirement for a bean class. The class cannot be converted into an xml schema type. An xml schema anyType will be used to define this class in the wsdl file.
WSDL2Java D:\liferay-plugins-sdk-6.1.0-ce-ga1\portlets\TestPlugin-portlet\2012061909055154­0\service.wsdl
Running Wsdl2javaAntTask with parameters:
verbose:false
debug:false
quiet:false
server-side:true
skeletonDeploy:false
helperGen:false
factory:null
nsIncludes:[]
nsExcludes:[]
factoryProps:[]
testCase:false
noImports:false
NStoPkg:{}
outputemoticon:\liferay-plugins-sdk-6.1.0-ce-ga1\portlets\TestPlugin-portlet\2012061909­0551540
protocolHandlerPkgs:
deployScope:
URLemoticon:\liferay-plugins-sdk-6.1.0-ce-ga1\portlets\TestPlugin-portlet\2012061909055­1540\service.wsdl
all:false
typeMappingVersion:1.2
timeout:45000
failOnNetworkErrors:false
printStackTraceOnFailure:true
namespaceMappingFile:null
username:null
:passwordnull
:noWrappedfalse
:allowInvalidURLfalse
:implementationClassNamenull
:classpathnull
http.proxyHost=null
http.proxyPort=null
http.proxyUser=null
http.proxyPassword=null
socks.proxyHost=null
socks.proxyPort=null
java.io.IOException: Type {http://model.test.liferay.com}Employee is referenced but not defined.
at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:­665)
at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)
Exception in thread "main" WSDL processing error for D:\liferay-plugins-sdk-6.1.0-ce-ga1\portlets\TestPlugin-portlet\2012061909055154­0\service.wsdl :
Type {http://model.test.liferay.com}Employee is referenced but not defined.
at org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask.execute(Wsdl2javaAntTask.java:30­4)
at com.liferay.util.ant.Java2WsddTask.generateWsdd(Java2WsddTask.java:108)
at com.liferay.portal.tools.WSDDBuilder._createServiceWSDD(WSDDBuilder.java:130)
at com.liferay.portal.tools.WSDDBuilder.build(WSDDBuilder.java:93)
at com.liferay.portal.tools.WSDDBuilder.main(WSDDBuilder.java:49)
Caused by: java.io.IOException: Type {http://model.test.liferay.com}Employee is referenced but not defined.
at org.apache.axis.wsdl.symbolTable.SymbolTable.checkForUndefined(SymbolTable.java:­665)
at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:545)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:518)
at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:495)
at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:361)
at java.lang.Thread.run(Thread.java:619)
Java Result: 1


Have you any suggestions to solve the problem?
Posted on 6/19/12 2:17 AM in reply to Patrick Momin.
I have same problem. Can you tell me solution?

Thak you
Posted on 7/12/12 2:53 AM in reply to Giuseppe Pantaleo.
For all , problem is in implement of XXXLocalServicesImp class. IN version liferay 6.1 dont necesarry correct methods in XXXServiceSoap.

->
http://www.liferay.com/community/forums/-/message_boards/message/14855175
Posted on 7/14/12 2:36 AM in reply to Petr Vašek.
Thanks , Its was very helpful.
Posted on 1/7/13 4:08 AM.
Try this URL
http://127.0.0.1:8080/TestPlugin-portlet/api/axis/Plugin_Test_EmployeeService­?wsdl
Posted on 2/5/13 1:35 AM in reply to Patrick Momin.
Nice..For Beginners..Its really nice article..Thanks for your Good work emoticon
Posted on 2/18/13 10:57 PM.
Nice Article kapil Thanks for sharing...emoticon
Posted on 5/15/13 2:29 AM.
Hi Kapil,

I have take your sample portlet and deploy it.But I am getting an error like this,

AXIS error

Could not generate WSDL!

There is no SOAP service at this location

I am accessing this url : http://127.0.0.1:8080/TestPlugin-portlet/api/axis/Plugin_Test_EmployeeService?ws­dl

Any help would be appreciated.Thankx in advance.

Thanks And Regards,
Abdulbasit F Shaikh
Posted on 6/7/13 4:54 AM.
Hi Kapil,

Thanks for such a nice doucment.I finally did this succesfully.

For Others,

If you are using Liferay 6.1.0 GA1(I don't know about others),then you need to follow the step number 21.The main culprit is the finder method.So first try to remove finder method and try this example.Make sure that you will not add any code of finder method in XXXLocalServiceImpl and XXXServiceimpl.And one more thing is that, if you are hitting an url and not getting output, then first try this http://127.0.0.1:8080/TestPlugin-portlet/api/axis, you will get the list of methods and one "wsdl" link, click on that, you will get your wsdl.cheers emoticon.

And for webservice client,first you need to create one dynamic web project.Then follow the steps of creating webservice client.Make sure that in step number 2,your newly created project(Dynamic web project) should be selected in client project.For E.G. in this case WebService project is selected.Make sure you tomcat is your normal tomcat not your liferay tomcat.And make sure that you dragged scroll to the top.You will find scroll on extreme left of window.

Thanks And Regards,
Abdulbasit F Shaikh.
Posted on 6/11/13 1:55 AM.
I am using Liferay 6.1.1
I need some help. Everything compiles, the wsdd is created, the deploy works with no error, the portlet page loads but when I try to see the wsdl:
http://127.0.0.1:8080/TestPlugin-portlet/axis/Plugin_Test_EmployeeService?wsd I am gettting error HTTP Status 404 - /TestPlugin-portlet/axis/Plugin_Test_EmployeeService,
and also I can not see service
http://127.0.0.1:8080/tunnel-web/axis
Posted on 3/21/14 1:18 PM.