1
votes

Does anyone know the steps so that OUR OWN portlets' service builder entities and methods show up when hitting localhost:8080/my-portlet/jsonws? All my entities are remote-service annotated. @JSONWebService is on all my classes. I've added a chunk of XML to web.xml (per http://www.liferay.com/community/wiki/-/wiki/Main/JSON+Web+Services - a very fine wiki otherwise). But I don't see anything happening.

I can browse to http://localhost:8080/api/jsonws and see the portal's JSON methods.

Have I missed a setting? Is there some additional configuration needed?

Thanks.

1

1 Answers

1
votes

It must be some miss-configuration:) Let me repeat the steps here.

After installing Liferay 6.1 CE GA1 try if JSONWS api is visible, by accessing following urls: http://localhost:8080/api/jsonws and (for example): http://localhost:8080/knowledge-base-portlet/api/jsonws

Now, create your portlet using latest Liferay SDK. Create at least one service method in *ServiceImpl. Run service builder

Add the following code in portlets 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.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>

Build war and finally deploy portlet to Liferay. After few moments, portlet will be deployed and available. JSONWS will scan your classes and find all service methods. To test if everything went ok, visit: http://localhost:8080/*portlet-context*/api/jsonws

That's all:)