Combination View Flat View Tree View
Threads [ Previous | Next ]
Gerald Rubin
JSON access to my service builder classes
January 12, 2012 7:55 AM
Answer

Gerald Rubin

Rank: Junior Member

Posts: 59

Join Date: October 23, 2011

Recent Posts

I'm in 6.1 GA1 on Tomcat from the bundle.

I've marked my entities with remote-service="true" and have the @JSONWebService annotation throughout all my classes. I've added
 1     <servlet>
 2        <servlet-name>JSON Web Service Servlet</servlet-name>
 3        <servlet-class>com.liferay.portal.kernel.servlet.PortalClassLoaderServlet</servlet-class>
 4        <init-param>
 5            <param-name>servlet-class</param-name>
 6            <param-value>com.liferay.portal.jsonwebservice.JSONWebServiceServlet</param-value>
 7        </init-param>
 8        <load-on-startup>0</load-on-startup>
 9    </servlet>
10    <servlet-mapping>
11        <servlet-name>JSON Web Service Servlet</servlet-name>
12        <url-pattern>/api/jsonws/*</url-pattern>
13    </servlet-mapping>
14    <servlet-mapping>
15        <servlet-name>JSON Web Service Servlet</servlet-name>
16        <url-pattern>/api/secure/jsonws/*</url-pattern>
17    </servlet-mapping>

to my portlet's web.xml as directed in the excellent Wiki at http://www.liferay.com/community/wiki/-/wiki/Main/JSON+Web+Services. I've redeployed and moved my service.jar to tomcat\lib\ext.

When I browse to http://localhost:8080/api/jsonws, I see all of the Liferay classes and methods (901 of them) listed, and I can execute methods and see the JSON response.

But I do not see any of my classes or methods.

What steps have I missed or is there a different URL to browse to for my portlet's classes to be presented in a similar way? If they cannot be rendered in a web page like the portal's classes and methods (and that would be a shame), how do I manually construct the URL to access a class.method?

Thank you.
Smilelws2010 lwz
RE: JSON access to my service builder classes
February 5, 2013 11:57 AM
Answer

Smilelws2010 lwz

Rank: Regular Member

Posts: 153

Join Date: December 16, 2010

Recent Posts

I had the above issue when I used the jav aclass com.liferay.portal.jsonwebservice.JSONWebServiceServlet isnide web.xml. I tried a day, but in vain.

Finally I changed the class to JSONServlet inside the web.xml
 1<servlet>
 2        <servlet-name>JSON Web Service Servlet</servlet-name>
 3        <servlet-class>com.liferay.portal.kernel.servlet.PortalClassLoaderServlet</servlet-class>
 4        <init-param>
 5            <param-name>servlet-class</param-name>
 6            <param-value>com.liferay.portal.servlet.JSONServlet</param-value>
 7        </init-param>
 8        <load-on-startup>0</load-on-startup>
 9    </servlet>
and I can access the methods in a different format,ie
http://localhost:8080/sample-portlet/api/jsonws/?serviceClassName=com.sample.service.SampleServiceUtil&serviceMethodName=findemail&serviceParameters=&email=abc@abc.com



But I really want to access service like
http://localhost:8080/api/secure/jsonws/dlapp/get-file-entries?repositoryId=10172&folderId=0
or
http://localhost:8080/api/secure/jsonws/dlapp/get-file-entries/repository-id/10172/folder-id/0

Any help is appreciated

Thanks
Smile