Oracle APEX_WEB_SERVICE MAKE_REST REQUEST raise ORA-29273 and ORA-24247 - oracle

I'm working on Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production and I need to develop a store procedure that access an API, I have to retrive the endpoint
https://api.my.host:8443/rest/ec/617643
I have set the oracle Wallet and added the certificate like this:
orapki wallet create -wallet /home/oracle/walletapi -pwd walletapi2022 -auto_login
orapki wallet add -wallet /home/oracle/walletapi -trusted_cert -cert /tmp/api.my.host.cer -pwd walletapi2022
I have set the ACE
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.my.host'
,lower_port => 8443
,upper_port => 8443
,ace => XS$ACE_TYPE(
privilege_list => XS$NAME_LIST('http')
,principal_name => 'MYUSER'
,principal_type => XS_ACL.ptype_db
)
);
DBMS_NETWORK_ACL_ADMIN.APPEND_WALLET_ACE (
wallet_path => 'file:/home/oracle/walletapi'
,ace => XS$ACE_TYPE(
privilege_list => XS$NAME_LIST('use_client_certificates', 'use_passwords')
,principal_name => 'MYUSER'
,principal_type => XS_ACL.ptype_db
));
Documentarion
In my store proc try this
...
l_clob := APEX_WEB_SERVICE.make_rest_request(
p_url => 'https://api.my.host:8443/rest/ec/617643'
,p_http_method => 'GET'
,p_wallet_path => 'file:/home/oracle/walletapi'
,p_wallet_pwd => 'walletapi2022'
);
...
Documentation
and this error is raised
ORA-29273: HTTP request failed
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 1182
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 782
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1127
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 756
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 1023
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 1371
ORA-06512: at "APEX_210200.WWV_FLOW_WEBSERVICES_API", line 626
ORA-06512: at line 6

Applying the solution with CREATE_ACL and ASSIGN_ACL changes only the value of the ACL column in DBA_NETWORK_ACLS and DBA_NETWORK_ACL_PRIVILEGES views. So I removed ACLs and PRIVs and restart.
Reviewing this question, I noticed that this error is for "APEX_210222" which is one of the schemas created during Apex installation.
I tried
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.my.host'
,lower_port => 8443
,upper_port => 8443
,ace => XS$ACE_TYPE(
privilege_list => XS$NAME_LIST('http')
,principal_name => 'APEX_210222'
,principal_type => XS_ACL.ptype_db
)
and the web_service_request is now working correctly.

Related

Connection Fail - fails with php 7.3 and 8.0 - tried wamp and xampp - attempting to access a sqlserver database

here is the entire error:
Connection fail
Array ( [0] => Array ( [0] => IM006 [SQLSTATE] => IM006 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed [message] => [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 5701 [code] => 5701 [2] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Changed database context to 'sodb'. [message] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Changed database context to 'sodb'. ) [2] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 5703 [code] => 5703 [2] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Changed language setting to us_english. [message] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Changed language setting to us_english. ) )
I have successfully installed the following extensions and they show up under phpinfo()
extension=php_sqlsrv_73_ts_x64.dll
extension=php_sqlsrv_73_nts_x64.dll
extension=php_pdo_sqlsrv_73_nts_x64.dll
extension=php_pdo_sqlsrv_73_ts_x64.dll
extension=php_sqlsrv_73_ts_x86.dll
extension=php_sqlsrv_73_nts_x86.dll
extension=php_pdo_sqlsrv_73_nts_x86.dll
extension=php_pdo_sqlsrv_73_ts_x86.dll
extension=php_sqlsrv_80_ts_x64.dll
extension=php_sqlsrv_80_nts_x64.dll
extension=php_pdo_sqlsrv_80_nts_x64.dll
extension=php_pdo_sqlsrv_80_ts_x64.dll
extension=php_sqlsrv_80_ts_x86.dll
extension=php_sqlsrv_80_nts_x86.dll
extension=php_pdo_sqlsrv_80_nts_x86.dll
extension=php_pdo_sqlsrv_80_ts_x86.dll
Here is my php code that is throwing this error:
$serverName = "***********************";
$connectionInfo = array( "Database"=>"*********", "UID"=>"*********", "PWD"=>"*************");
$maxret = 3;
$conn = false;
do {
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn !== false) break;
sleep(2);
} while($maxret-- >= 0);
I have installed ODBC related libraries
I'm working on three different machines, with different IP addresses, all enabled on azure firewall (sql database is on azure). On one of the machines it works, two of the machines generates the error above.
Identical php.ini files on two of the machines and in wamp the listed extensions are the same. On one machine the php script runs, on another it generates an error.
The solution to this problem was to install Microsoft SQL Server Management ...
MSMSS

Oracle Datapump: Invalid operation at line 6224

I've a Oracle dump file that I'm trying to import to AWS RDS Oracle 12.1.0.2.v17
database.
The dump file looks like this:
$ strings EXPDP.dmp | head -n 6
_|lM
"PACOPROD"."SYS_EXPORT_SCHEMA_01"
IBMPC/WIN_NT64-9.1.0
unicode
AL32UTF8
12.01.00.00.00
The commands I'm running is:
DECLARE
hdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.OPEN( operation => 'IMPORT', job_mode => 'SCHEMA', job_name=>null, version=>'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.dmp', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''PACOPROD'')');
DBMS_DATAPUMP.START_JOB(hdnl);
END;
/
The response is:
Error report -
ORA-39002: invalid operation
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6224
ORA-06512: at line 7
The closes similar issue I've found is this, even though it's not exactly the same error message and in my case both source and target db is running 12.1.
I think the issue is one of the following:
A) The DMP file is corrupt.
B) I'm doing something wrong.
I've no clue how to get further though. Where shall I dig or what should I try to go forward?
Try to add a log file to the operation. It some times contain more information:
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.KU$_FILE_TYPE_LOG_FILE);

Insufficient privileges registering xml schema in database

using this instruction :
DBMS_XMLSCHEMA.REGISTERSCHEMA(filenamer,clobFile);
I have the following errors
ORA-31084: error while creating table "USER"."Document1592_TAB" for element "Document"
ORA-01031: insufficient privileges
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 72
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 33
Of course this user can create tables, do you know where it could come from ?
thank you
Probably you don't have privileges to create,alter,drop,... types.
Also you can try to register xsd without creating any objects
DBMS_XMLSCHEMA.REGISTERSCHEMA(
schemaurl => filenamer
schemadoc => clobFile
gentypes => FALSE
gentables => FALSE
);

FTP a file from a Server's Subfolder using PL/SQL

I'm trying to get a file from a Windows Server to our Oracle Application Server directory named EXT_TAB_DATA.
I have followed the sample of a similar SO post (PL/SQL FTP API binary vs ascii mode), using Tim Hall's FTP Package.
Code Block
set serveroutput on
DECLARE
l_conn UTL_TCP.connection;
BEGIN
L_CONN := FTP.login (p_host => 'sample.corp.server' -- this is a sample, not the real IP address
p_user => 'corporate/user1', -- this is a sample, not the real User
p_port => '21',
p_pass => 'pwd');
ftp.binary(p_conn => l_conn);
ftp.get (p_conn => l_conn,
p_from_file => '101_Test.csv',
p_to_dir => 'EXT_TAB_DATA',
p_to_file => '101_Test_Trans.csv');
ftp.logout(l_conn);
END;
/
However, the file i'm trying to transfer is located in a subfolder named "Payroll_Folder" in "sample.corp.server.
Seems FTP.login only checks the main directory of the host, and not inside subfolders.
How can I get the the file '101_Test.csv' from the Server/Directory "sample.corp.server/Payroll_Folder"?
Change
p_from_file => '101_Test.csv'
to
p_from_file => 'Payroll_Folder/101_Test.csv'

Move a file from one server to another server via plsql or shell

I have a server with details :
server ip: 192.168.141.96 : 21 credentials: user: tss password: T#l30P#ss path: /home/ttt/
This is the server where a file is getting generated. I want to move this file to another server with credentials
Host: sftp://sftpabc.learn.com
User name: abc
Password: jQrE7wvg
Port: 22
import dir: upload/source
I am trying to use the following plsql script for this :
DECLARE
l_conn UTL_TCP.connection;
begin
l_conn := ftp.login('192.168.141.96', '21', 'tss', 'T#l30P#ss');
ftp.ascii(p_conn => l_conn);
FTP.GET(P_CONN => L_CONN,
P_FROM_FILE => 'filename_test.csv',
p_to_dir => 'DIR_INBOUND',
p_to_file => 'test_get.txt');
ftp.logout(l_conn);
END;
But this is not executing and no file is getting transgerred. Is there a shell script/plsql script for this ?
What do you mean by 'is not executing'. What is the error? A quick search shows that you may be using this site as reference for your code. If that is the case, did you make sure to compile the ftp.pks and ftp.pkb in your database?

Resources