Download plugin portlet from following URL
Following is the step by step description of generating a custom liferay
plugin service and exposing it as JSON Web Service.
STEP: 1 Create a liferay plugin project and create new service
Here is the sample service.xml
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE service-builder
PUBLIC "-//Liferay//DTD
Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com.meera.json">
<author>meera</author>
<namespace>json</namespace>
<entity name="Student"
local-service="true" remote-service="true">
<column name="studentId"
type="long" primary="true"
/>
<column name="studentName"
type="String" />
</entity>
</service-builder>
|
Make sure remote-service=”true” in
entity tag declaration.
STEP: 2 Build the service.
STEP: 3 write you custom method
implementation in StudentServiceImpl.java
public
com.meera.json.model.Student getStudent(long studentId)
throws
com.liferay.portal.kernel.exception.PortalException,
com.liferay.portal.kernel.exception.SystemException
{
return
StudentLocalServiceUtil.getStudent(studentId);
}
|
Note: Here I am using existed method only don’t confuse.
You can write your custom method implementation instead of my method.
STEP: 4 build the service using
command ant build-service from your eclipse ant view
STEP: 5 Add the following <servlet>
and <servlet-mapping> Entries to portlet’s web.xml
file
<servlet>
<servlet-name>JSON Web
Service Servlet</servlet-name>
<servlet-class>com.liferay.portal.kernel.servlet.PortalClassLoaderServlet</servlet-class>
<init-param>
<param-name>servlet-class</param-name>
<param-value>com.liferay.portal.servlet.JSONServlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JSON Web
Service Servlet</servlet-name>
<url-pattern>/api/jsonws/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JSON Web
Service Servlet</servlet-name>
<url-pattern>/api/secure/jsonws/*</url-pattern>
</servlet-mapping>
|
STEP: 6 deploy the portlet using ant
deploy command from eclipse ant view
STEP: 7 to access your json web services enter the following url –
Note: if you access above url you will get blank page in browser but
don’t worry. Make sure no exception will be occurred in console. Go through
following url
Following is full URL to get json data
according to my example
http://localhost:8080/LiferayCustomJsonWebService-portlet/api/jsonws/?serviceClassName=com.meera.json.service.StudentServiceUtil&serviceMethodName=getStudent&serviceParameters=[studentId]&studentId=1
|
Note:
Change port number according
to your environment and change portlet-context
name according to your portlet context name
The message in Liferay 6.1.1 is {"exception":"No JSON web service action associated with path /student/get-stutend and method GET for //LiferayCustomJsonWebService-portlet"}
ReplyDelete{"exception":"Please sign in to invoke this method"}
ReplyDeleteHow to resolve this issue ?
use this url
ReplyDeletehttp://localhost:8080/LiferayCustomJsonWebService-portlet/api/jsonws/student/get-student/studentId/1
or
http://localhost:8080/LiferayCustomJsonWebService-portlet/api/jsonws/student/get-student?studentId=1
follow reference links
http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/json-web-services
http://informatik-hub.blogspot.hk/2012/12/part-3-custom-liferay-plugin-json-web.html
Remarkably! It is as if you read my mind! A person appear to know therefore considerably relating to this, just like you authored the book inside it or something. I feel that you can do with a few images to drive the content residence a bit, on top of that, this really is great weblog. The outstanding study. I will definitely review again. web design tips
ReplyDeleteGood post , I am going to spend more time researching this topic top web design agencies
ReplyDeleteThanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. Vancouver SEO Agency
ReplyDeletePleasant to be going by your web journal once more, it has been months for me. Well this article i've been sat tight for so long. I require this article to finish my task in the school, and it has same theme with your article. Much obliged, incredible offer.benchtop temperature and humidity environmental test chamber
ReplyDeleteYou hit the nail on the head! I was coming to coupons, you could generally recover for things at the stores you shop at. besimple.com/
ReplyDeleteI am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job ! www.repeatprecision.com
ReplyDeleteI know this is extremely boring and you are skipping to succeeding comment, however I just needed to throw you a big thanks you cleared up some things for me!
ReplyDelete온라인섯다
Can I simply say what relief to get somebody that in fact knows what they're dealing with on-line. You actually know how to bring a concern to light to make it essential. Workout . should ought to see this and can see this side of your story. I cant think you're less well-known simply because you definitely hold the gift.
ReplyDeleteCan I simply say what relief to get somebody that in fact knows what they're dealing with on-line. You actually know how to bring a concern to light to make it essential. Workout . should ought to see this and can see this side of your story. I cant think you're less well-known simply because you definitely hold the gift.
Can I simply say what relief to get somebody that in fact knows what they're dealing with on-line. You actually know how to bring a concern to light to make it essential. Workout . should ought to see this and can see this side of your story. I cant think you're less well-known simply because you definitely hold the gift.
스포츠토토
A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post.
ReplyDelete토토사이트