4.5 Creating RESTful Web Services
Create RESTful web services using the Modules, Templates and Handlers pages.
To create a RESTful web service, you need to:
-
Define a resource module
-
Define a resource template
-
Define one or more resource handlers such as GET, PUT, POST or DELETE. Optionally, define parameters that you need to pass to the resource handler.
The following sections provide information on how to create resource modules, resource templates and resource handlers.
4.5.1 Managing Resource Modules
You can define, edit and delete resource modules in the Modules page.
To navigate to the Modules page, in the REST Overview page, click Modules in Objects, or from the menu in the header, select Modules.
The module attributes displayed by default in card view are shown in the following figure.
The module status can be published or unpublished. If the status is unpublished, the icon is displayed in a red color.
Click the module name in card view to go to the Templates page for that module. You can also navigate to the Templates page through the context menu.
The actions available in the context menu are:
-
Navigating to the Templates page for a module
See Also:
About the REST Search Toolbar4.5.1.2 Editing a Resource Module
This section describes how to edit a resource module.
- In the Modules page, for the specific module, click
, and select Edit.
- Edit the required fields and click Save. For a description of the fields, see Creating a Resource Module.
4.5.2 Managing Resource Templates
You can define, edit and delete resource templates for a module in the Templates page.
To navigate to this page, in the Modules page, click for a module and select Templates, or click the name
of the module in card view.
At the top of the page, the module card is available with context menu options such as Edit, Delete, Publish and Export.
The templates attributes displayed by default in card view are shown in the following figure.
Click the template name in card view to go to the Handlers page. You can also navigate to the Handlers page through the context menu.
The actions available in the context menu are:
-
Navigating to the Handlers page for the template
4.5.3 Managing Resource Handlers
You can create, edit and delete resource handlers for a template in the Handlers page.
To navigate to this page, in the Templates page, click for a template and select Handlers,
or click the name of the template in card view.
At the top of the page, the template card is available with context menu options such as Edit and Delete.
Tthe handler attributes displayed by default in card view are shown in the following figure.
The HTTP Method can be one of the following: GET, PUT, POST and DELETE.
Click the handler name to go to the HTTP method page or you can also navigate to the HTTP method page using the context menu.
The actions available in the context menu are:
-
Note:
This option is not available if the template has all four handlers created (GET, POST, PUT, DELETE). -
Navigating to the Handler HTTP method page
4.5.3.2 Example: Inserting a Record using a POST Handler
The following example illustrates how to insert a record in the DEPT table.
Prerequisites
-
Using the worksheet in the SQL page, create a DEPT table.
CREATE TABLE DEPT( DEPTNO number(2,0), DNAME varchar2(14), LOC varchar2(13), CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO) )
-
Create a module named example. See Creating a Resource Module
-
Create a template named emp/ for the module. See Creating a Resource Template
4.5.4 Viewing Resource Handler Details and Managing Parameters
You can view resource handler details and manage parameters in the HTTP method page.
To navigate to this page, for a specific handler, click and then select Details or click the
name of the handler in card view.
At the top of the page, the handler card is available with context menu options such as Edit and Delete.
The Handler HTTP method page has two major sections:
-
A code editor for executing the SQL or PL/SQL source code that was defined in the resource handler. You can execute the code, save, undo, redo, download and clear output.
-
A section for managing parameters required for running the HTTP method.
By default, the parameters are displayed in grid view. The attributes displayed on a parameter in card view are shown in the following figure.
The actions available in the context menu are:
See Also:
About the REST Search Toolbar