web-servicesjacksonliferayliferay-service-builder

Liferay 7 Service Builder without creating database table and will call/invoke/consume RESTful web services API


I'm implementing Liferay 7 Service Builder which should not create database table and will call RESTful web services API. The web services to be invoked are custom and outside the Liferay; they have nothing to do with Liferay at all. The web services provide JSON format data to Service Builder. The Service Builder shall map it to its generated POJO class, and by using Jackson library would convert it back to JSON string. The portlet which would call the Service Builder (XxxServiceImpl) converts the JSON string to POJO object and render it on JSP.

I've search the world wide web to no avail. I hope anybody can help me.

Thank you.


Solution

  • By creating an empty entity, you'll get the services generated for you, though with no model classes - they'd be up to you to create yourself:

    <service-builder package-path="com.example.foo">
        <namespace>FOO</namespace>
        <entity name="Foo" local-service="true" remote-service="true">
        </entity>
    </service-builder>
    

    This will generate FooService, FooLocalService and the matching implementation classes, but no FooModel etc. - as this is something that you'd persist yourself anyways, you can (and should) build the model classes on your own. Liferay's ServiceBuilder would help you with the database persistence, but not with any other persistence.