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.
See Also:
-
Creating a RESTful Service in Oracle REST Data Services Quick Start Guide
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 ToolbarImporting a Resource Module
Note:
You can import an OpenAPI version 2.0 or 3.0 document in JSON format only.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.
Publishing/Unpublishing a Resource Module
This section describes how to make a resource module available or not.
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
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
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
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. For more information about the editor, see Executing SQL Statements in the Code Editor.
Implicit parameters used in REST service handlers are displayed in a scrolling list towards the right side of the editor. See Implicit Parameters
-
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 ToolbarImplicit Parameters
This section describes the implicit parameters in the Resource Handler Details page. These parameters are automatically added to the resource handlers.
Table 4-1 Implicit Parameters
Name | Type | Access Mode | HTTP Header | Description |
---|---|---|---|---|
|
BLOB |
IN |
N/A |
Specifies the body of the request as a temporary BLOB. |
|
CLOB |
IN |
N/A |
Specifies the body of the request as a temporary CLOB. |
|
VARCHAR |
IN |
|
Specifies the MIME type of the request body, as indicated by the Content-Type request header. |
|
VARCHAR |
IN |
N/A |
Specifies the authenticated user for the request. If no user is authenticated, then the value is set to null. |
|
VARCHAR |
OUT |
|
Specifies the location where Oracle REST Data Services must forward a GET request to produce the response for this request. |
|
NUMBER |
IN |
N/A |
Specifies the zero-based offset of the first row to be displayed on a page. |
|
NUMBER |
IN |
N/A |
Specifies the maximum number of rows to be retrieved on a page. |
|
NUMBER |
IN |
N/A |
Specifies the zero based page offset in a paginated request. Note:
|
|
NUMBER |
IN |
N/A |
Specifies the maximum number of rows to be retrieved on a page. The |
|
NUMBER |
IN |
N/A |
Specifies the one-based index of the first row to be displayed in a paginated request. |
|
NUMBER |
IN |
N/A |
Specifies the one-based index of the last row to be displayed in a paginated request. |
|
NUMBER |
OUT |
|
Specifies the HTTP status code for the request. |
For more information about the implicit parameters, see Oracle REST Data Services Developer's Guide.