简体   繁体   中英

How to create Liferay JSON web service for existing tables?

I am developing a mobile app which retrieves data from a Liferay-based portal. I am using JSON web services to access the data which works well for eg Blog Entries. How can I make a new web service for existing tables? Each tutorial I have found starts with the definition of a new entity (ie database table), but I don't need that. I just want to access existing data in such a way which is not provided by system ws, eg to filter web content which have a specific structure.

Note: I tried also a workaround, I managed to make a struts action which prints out the desired JSON data and returns null. When I enter the address for the action in a browser, I see the JSON string. But if I put it in my mobile app, I see an HTML code, it seems that it is redirected to the home page of the portal.

Neat trick if you don't want to define a new entity with servicebuilder: Just leave the entity empty, this defines just a type, but no fields, eg no underlying table. Then implement your methods by just delegating to whatever persistence you'd like to access (or even without any persistence).

  <Entity name="Foo" local-service="true" remote-service="true">
  </Entity>

This will create FooServiceImpl and FooLocalServiceImpl that you can use to implement your business logic, without any attached database table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM