Web Service on RAP [message #1839649] |
Thu, 25 March 2021 03:54  |
Eclipse User |
|
|
|
Good day, everyone,
In order to provide other systems to read/write data from the RAP application instead of allowing direct access to the database.
I found Web Service might be a good solution, can someone guide me how to do it? And what plugins/packages do I need?
Thank you so much!
David
|
|
|
Re: Web Service on RAP [message #1839874 is a reply to message #1839649] |
Tue, 30 March 2021 13:22  |
Eclipse User |
|
|
|
Hi David,
in principle, you could expose one or more servlets under a given URL. You can use the extension point "org.eclipse.equinox.http.registry.servlets" (in the "Extensions" registry of the plugin.xml Editor) and register a class that extends javax.servlet.http.HttpServlet .
In the extension point you enter the fully qualified name of your servlet for the "class" property and the "alias" property is that determines the URL, under which the servlet will be accessible, e.g. "/api". The servlet would than answer on requests to "<base URL>/api".
From there you would have to implement the request and response processing yourself. There might be some Java libs to help with that (e.g. JSON serializer/deserializer) etc. Depending on your use case, it might not be the most convenient way to provide a RESTful API, since it might not be very easy for use different URLs with more parts (like /api/v1/foo/bar), since the servlet mapping doesn't work dynamically. Maybe it would be possible to expose the API in a different WAR file and deploy it next to the RAP app?
HTH
Ben
|
|
|
Powered by
FUDForum. Page generated in 0.04045 seconds