Foren
JSON access to my service builder classes
Gerald Rubin, geändert vor 12 Jahren.
JSON access to my service builder classes
Junior Member Beiträge: 59 Beitrittsdatum: 23.10.11 Neueste Beiträge
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
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.
I've marked my entities with remote-service="true" and have the @JSONWebService annotation throughout all my classes. I've added
<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.jsonwebservice.JSONWebServiceServlet</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>
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, geändert vor 11 Jahren.
RE: JSON access to my service builder classes
Regular Member Beiträge: 160 Beitrittsdatum: 16.12.10 Neueste Beiträge
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
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
Finally I changed the class to JSONServlet inside the web.xml
<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>
and I can access the methods in a different format,iehttp://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