13.10 EXECUTE_WEB_SOURCE Procedure

This procedure executes a web source operation based on module name, operation and URL pattern (if required). Use the t_parameters array to pass in values for declared web source parameters. Web Source invocation is done based on metadata defined in Shared Components.

Syntax

procedure execute_web_source (
    p_module_static_id in varchar2,
    p_operation        in varchar2,
    p_url_pattern      in varchar2         default null,
    p_parameters       in out t_parameters );

Parameters

Table 13-8 EXECUTE_WEB_SOURCE Procedure Parameters

Parameter Description

p_module_static_id

Static ID of the web source module.

p_operation

Name of the operation, e.g. POST, GET, DELETE.

p_url_pattern

If multiple operations with the same name exist, specify the URL pattern, as defined in Shared Components, to identify the web source operation.

p_parameters

Parameter values to pass to the external web source.

Returns

p_parameters

Array with OUT parameter values, received from the web source module.

Example

This example assumes a REST service being created on the EMP table using ORDS and the "Auto-REST" feature (ORDS.ENABLE_OBJECT). Then a Web Source Module for this REST service is being created in Shared Components as "ORDS EMP".

The POST operation has the following "Request Body Template" defined:{"empno": "#EMPNO#", "ename": "#ENAME#", "job": "#JOB#", "sal": #SAL#}

Parameters are defined as follows:

Name Direction Type

EMPNO

IN

Request Body

ENAME

IN

Request Body

SAL

IN

Request Body

JOB

IN

Request Body

RESPONSE

OUT

Request Body

Content-Type

IN

HTTP Header

PL/SQL code to invoke that web source operation looks as follows:

declare
    l_params apex_exec.t_parameters;
begin
    apex_exec.add_parameter( l_params, 'ENAME', :P2_ENAME );
    apex_exec.add_parameter( l_params, 'EMPNO', :P2_EMPNO );
    apex_exec.add_parameter( l_params, 'SAL',   :P2_SAL   );
    apex_exec.add_parameter( l_params, 'JOB',   :P2_JOB   );

    apex_exec.execute_web_source(
        p_module_static_id => 'ORDS_EMP',
        p_operation        => 'POST',
        p_parameters       => l_params );

    :P2_RESPONSE := apex_exec.get_parameter_clob(l_params,'RESPONSE');
end;