Utl_http authentication
Not an Apex question, but hoping some of the Oracle Web Gurus may know the answer, or can point me in the right direction.
I need to retrieve XML into my 10g database, from a website that requires authentication. Username and Password is done via HTML form on the front page, once authenticated a session (SID) is produced. All interaction from then on is via session.cgi in the URL.
Is there any way I can use utl_http to interact with the website , to POST the username and password (via the login form) , and retrieve the session ID? So I can make further URL calls to retrieve the XML.
Thanks in advance.
The docs describe the entire API. Please read through with a little more diligence. You can have the login form send a 'POST' request as belowreq := UTL_HTTP.BEGIN_REQUEST (url=>'www.abc.com', method=>'POST');
UTL_HTTP.SET_HEADER (r => req,
name => 'Content-Type',
value => 'application/x-www-form-urlencoded');
UTL_HTTP.SET_HEADER (r => req,
name => 'Content-Length',
value =>' <length of data posted in bytes>');
UTL_HTTP.WRITE_TEXT (r => req,
data => 'username=value1&passwd=value2...');
resp := UTL_HTTP.GET_RESPONSE
(r => req);
.... process response Varad
Similar Messages
-
How to perform authentication on proxy using utl_http package?
Hi,
I am using Oracle 8i database (ver:8.1.7). I want to use the utl_http package to perform http requests. Within my company, I am forced to use a proxy and I have to be authenticated on that proxy. How can I authenticate myself on the proxy using utl_http.request function on Oracle 8i?
Thanks a lot.
Paulo.UTL_HTTP
The UTL_HTTP package makes Hypertext Transfer Protocol (HTTP) callouts from SQL and PL/SQL. You can use it to access data on the Internet over HTTP.
With UTL_HTTP, you can write PL/SQL programs that communicate with Web (HTTP) servers. UTL_HTTP also contains a function that can be used in SQL queries. The package also supports HTTP over the Secured Socket Layer protocol (SSL), also known as HTTPS, directly or through an HTTP proxy. Other Internet-related data-access protocols (such as the File Transfer Protocol (FTP) or the Gopher protocol) are also supported using an HTTP proxy server that supports those protocols.
When the package fetches data from a Web site using HTTPS, it requires Oracle Wallet Manager to set up an Oracle wallet. Non-HTTPS fetches do not require an Oracle wallet.
See Also:
Chapter 102, "UTL_URL"
Chapter 100, "UTL_SMTP"
Oracle Advanced Security Administrator's Guide for more information on Wallet Manager
This chapter discusses the following topics:
UTL_HTTP Constants, Types and Flow
UTL_HTTP Exceptions
UTL_HTTP Examples
Summary of UTL_HTTP Subprograms
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_http.htm#ARPLS070
Joel P�rez -
How to add WebService authentication in pl/sql using UTL_HTTP
Hi,
I am passing SOAP request and getting output as a soap response from WebService using UTL_HTTP.
Calling Web service client call from the PL/SQL procedure.
Java web service is a service producer.
Now we needs to add security to the application we are planing to add some of the userid/pwd credientials.
So what needs to be add sql code in the sq/sql for making client call.
i checked from the few of the articles. it shown like
UTL_HTTP.set_authentication(http_req, 'username', 'password' );
is it enough for making clent call or any other changes are required.
Please let me know and any code to be implemented in the jave side aslo(if you knows) :-)
Thanks,
Pradeep.Okay, backtrack.
A web server can deliver all kinds of content. From static HTML pages, to XML files and videos and dynamic content. Including reports.
The communication language (protocol) used to talk to a web server is HTTP.
UTL_HTTP is an Oracle PL/SQL library that implements the client side of this communication. It allows the developer to write code that acts like a web browser and communicates with a web server.
Now what do you not understand and cannot use?
HTTP is not simple and easy. You need to understand the basics of this communication language in order to communicate successfully with the web server. Like knowing the difference between GET and PUT and POST commands, how the URL query string works and so on.
Once you know that, you can look at how the web server provides reports. How do you authenticate as a web browser with the web reporting system? What URLs do you use to access which reports? How do you pass name-values to the web server as report parameters? What HTTP response formats (MIME types) does the web report server provide? Which one do you plan to use and how do you parse that response into a meaning structured data format?
If you're thinking it is "easy", think again. Sure, someone here can provide sample code that for example grabs a CSV report file from a web server and (using a pipeline table function), turn that into rows and columns. But that will not teach you the fundamentals you need to know and not equip you with dealing with the problem with your own brains, hands and keyboard.
PS. In other words, learn to crawl and walk before trying to run. Get to grips with how HTTP works before diving into the deep end of web report integration. -
Issues with using utl_http with Oracle Wallet
Hello Everyone,
We are experimenting with Oracle wallet and utl_http and are attempting to do an https transfer and we are facing some problems. I will appreciate your help greatly if you can advise on what could be wrong. We are on db version 10.2.0.1 and Unix HP-UX. The intention ping an https url and get a simple 200 response. Future development would include get/post XML documents from that url and other interesting stuff. I understand that utl_http with Oracle wallet can be used for this purpose.
The wallet has been created and the ewallet.p12 exists. We downloaded the SSL certificate from the url's website and uploaded into the wallet.
Everything works if I put in a url with plain http. However, it does not work with an HTTP*S* url.
With HTTPS when I run the below code I get the following error. Again, greatly appreciate your time and help because this is the first time we are using Oracle wallet manager and do not know where to go from here.
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1029
ORA-29268: HTTP client error
declare
url varchar2(225);
req utl_http.req;
resp utl_http.resp;
my_proxy BOOLEAN;
name varchar2(2000);
value varchar2(2000);
V_proxy VARCHAR2(2000);
v_n_proxy varchar2(2000);
v_msg varchar2(100);
v_len PLS_INTEGER := 1000;
BEGIN
-- Turn off checking of status code.
utl_http.set_response_error_check(FALSE);
--Set proxy server
utl_http.set_proxy('my-proxy');
utl_http.set_wallet('file:<full Unix path to the wallet on DB server>','wallet998');
req := utl_http.begin_request('https://service.ariba.com/service/transaction/cxml.asp');
--Set proxy authentication
utl_http.set_authentication(req, 'myproxyid', 'myproxypswd','Basic',TRUE); -- Use HTTP Basic
resp := utl_http.get_response(req);
FOR i IN 1..utl_http.get_header_count(resp) LOOP
utl_http.get_header(resp, i, name, value);
dbms_output.put_line(name || ': ' || value);
END LOOP;
utl_http.end_response(resp);
exception
when others then
dbms_output.put_line(sqlerrm);
END;I tried this using plsql ...
declare
SOAP_URL constant varchar2(1000) := 'http://125.21.166.27/cordys/com.eibus.web.soap.Gateway.wcp?organization=o=WIPRO,cn=cordys,o=itgi.co.in';
request UTL_HTTP.req;
begin
dbms_output.put_line('Begin Request');
request := UTL_HTTP.begin_request(SOAP_URL,'POST',UTL_HTTP.HTTP_VERSION_1_1);
dbms_output.put_line('After Request');
exception
when others then
dbms_output.put_line('Error : '||sqlerrm);
end;The output was ...
Begin Request
Error : ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1029
ORA-12535: TNS:operation timed outIt seems to be an issue with the webservice, plz check if its available & allowing requests. -
hi
I am getting the following error while calling the procedure in the batch process
ORA-06512: at "SYS.UTL_HTTP", line 1022
ORA-29270: too many open HTTP requests
Could you please help me on this? As this is getting affected in the live databases.
ORA-06512: at "SYS.UTL_HTTP", line 1022
ORA-29270: too many open HTTP requests
CREATE OR REPLACE PROCEDURE Send_To_Spg(
PTRANSACTION_ID IN VARCHAR2,
PCHANNEL_TYPE IN VARCHAR2 DEFAULT NULL,
PCSS_ORDER_NUMBER IN VARCHAR2 DEFAULT NULL,
PTELEPHONE_NUMBER IN VARCHAR2 DEFAULT NULL,
PSCENARIO_TYPE IN VARCHAR2 DEFAULT NULL,
PCUSTOMER_REQUIRED_DATE IN VARCHAR2 DEFAULT NULL,
PCUSTOMER_REQUIRED_TIME IN VARCHAR2 DEFAULT NULL,
PCANCELLATION_REASON IN VARCHAR2 DEFAULT NULL,
PCANCELLATION_NOTES IN VARCHAR2 DEFAULT NULL,
PSMPF_RETENTION IN VARCHAR2 DEFAULT NULL,
PEMERGENCY_WINBACK IN VARCHAR2 DEFAULT NULL,
PCSS_PROJECT_ID IN VARCHAR2 DEFAULT NULL,
PCSS_ORDER_NOTES IN VARCHAR2 DEFAULT NULL,
PREASON_FOR_CESSATION IN VARCHAR2 DEFAULT NULL,
P_RESPONSE OUT VARCHAR2,
PSMART_USER_ID IN VARCHAR2 DEFAULT NULL,
PORACLE_ERROR OUT VARCHAR2,
PORACLE_ERROR_MESSAGE OUT VARCHAR2,
PRESPONSE_TIME OUT NUMBER,
PDATA_TRANSFER_STATUS OUT VARCHAR2)
IS
v_scenario_type VARCHAR2(20); -- Varialble to Hold Time Out of every request to SPG
v_transaction_time NUMBER; -- Total time in which Request to SPG was processed
v_record_inserted_at DATE; -- Date/Time about the record insertion to the Error Handler
v_start_time NUMBER; -- Variable to hold Start Time for calculationg Transaction Time
v_url VARCHAR2(32767);-- URL to use when sending data to SPG
vtransaction_id VARCHAR2(18); -- Variable to hold Transaction ID for the request
v_buffer VARCHAR2(32760);-- Variable to read response from the SPG interface
v_timeout PLS_INTEGER; -- Time Out for each Transaction
v_oracle_err_msg VARCHAR2(600); -- Variable to hold Oracle Error Message
v_resp UTL_HTTP.RESP; -- Response Object
v_req UTL_HTTP.REQ; -- Request Object
v_userid_pwd SMT_ORACLE_PARAMETERS%ROWTYPE; --Variable declared to contain User ID & Password
vl_RetCode VARCHAR2(5000);
vl_std_returnCode VARCHAR2(3000);
--PDATA_TRANSFER_STATUS Holds the Data Transfer Status which can have possible values as
-- N => Data Has not been sent to SPG
-- Y => Received Successful response from SPG
-- F => On the First try to Send data to SPG Oracle Error Occured or response from SPG was a faulure
-- S => On the Second try to Send data to SPG Oracle Error Occured or response from SPG was a faulure
-- T => Data Has been transferred to the Error Log Table
-- X => Data need not be transfered to Error Log Table.
--Location of the timeout, URL & User Id & Password in Standing Data.
c_url_stopwlr SMT_ORACLE_PARAMETERS.PARAMETER_CODE%TYPE:='SPG_WLR';-- Stop WLR URL
c_url_cancelown SMT_ORACLE_PARAMETERS.PARAMETER_CODE%TYPE:='SPG_OWN';-- Cancel own URL
c_url_cancelother SMT_ORACLE_PARAMETERS.PARAMETER_CODE%TYPE:='SPG_OTH';-- Cancel other URL
c_url_amendcrd SMT_ORACLE_PARAMETERS.PARAMETER_CODE%TYPE:='SPG_CRD';--Amend CRD URL
c_spg_useridpwd SMT_ORACLE_PARAMETERS.PARAMETER_CODE%TYPE:='SPGIDPWD'; --Contains user id and pwd
ctimeout smt_parameters.parameter_code%TYPE:='SPGTO'; --This holds the timeout parameter
BEGIN
--In case the calling batch process can pass this value this SQL read will not be required & can be deleted
--Read data transfer status for the transaction Id
SELECT data_transfer_status INTO PDATA_TRANSFER_STATUS FROM SPG_INTERFACE_TABLE
WHERE transaction_id = PTRANSACTION_ID;
--Record the start time
v_start_time:=DBMS_UTILITY.GET_TIME;
--If Data transfer status is S then send the record to error handler
IF PDATA_TRANSFER_STATUS = 'S' THEN
Error_Handler(PTRANSACTION_ID,PSMART_USER_ID,PORACLE_ERROR,PORACLE_ERROR_MESSAGE,v_record_inserted_at,PDATA_TRANSFER_STATUS);
ELSE
--In case Data Tranfer Status is something other than S then send the request to SPG
--Initialise other variables which will be populated during the journey
P_RESPONSE := '';
PORACLE_ERROR := NULL;
PORACLE_ERROR_MESSAGE := NULL;
PRESPONSE_TIME := 0;
--Read timeout parameter from standing data.
BEGIN
SELECT VALUE INTO v_timeout FROM smt_parameters WHERE parameter_code=ctimeout;
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_timeout:=30;
WHEN OTHERS THEN
v_timeout:=30;
END;
-- Construct the URL for Stop WLR Scenario
IF PSCENARIO_TYPE = 'STOP_WLR' THEN
BEGIN
-- Read the Initial URL from Standing Data
SELECT VALUE
INTO v_url
FROM SMT_ORACLE_PARAMETERS
WHERE parameter_code = c_url_stopwlr
AND host_id = ( SELECT host_id
FROM SMART_HOSTS A
WHERE EXISTS ( SELECT 1
FROM DB_PARAMETERS b
WHERE A.hostname = b.hostname
AND A.database_id = b.database_id));
--handle unforseen exception
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_url:='Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_winback_details'; --After testing the same, URL will be fetched from the Query
WHEN OTHERS THEN
v_url:='Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_winback_details'; --After testing the same, URL will be fetched from the Query
END;
--construct the URL depending on the parameters to be passed to the url
v_url := v_url || '?';
v_url := v_url || 'p_data_entered=' || Smart_Urlencode('xmloverhttp') || '&';
v_url := v_url || 'p_channel_type=' || Smart_Urlencode(PCHANNEL_TYPE)|| '&';
v_url := v_url || 'p_css_start_order_no=' || Smart_Urlencode(PCSS_ORDER_NUMBER)|| '&';
v_url := v_url || 'p_tel_no=' || Smart_Urlencode(PTELEPHONE_NUMBER)|| '&';
v_url := v_url || 'p_crd=' || Smart_Urlencode(PCUSTOMER_REQUIRED_DATE)|| '&';
v_url := v_url || 'p_take_over_time=' || Smart_Urlencode(PCUSTOMER_REQUIRED_TIME)|| '&';
v_url := v_url || 'p_retainsmpf=' || Smart_Urlencode(PSMPF_RETENTION)|| '&';
--v_url := v_url || 'p_emergency_winback=' || Smart_Urlencode(PEMERGENCY_WINBACK)|| '&';
v_url := v_url || 'p_projectno=' || Smart_Urlencode(PCSS_PROJECT_ID)|| '&';
v_url := v_url || 'p_ordernotes=' || Smart_Urlencode(PCSS_ORDER_NOTES)|| '&';
v_url := v_url || 'p_reason_cessation=' || Smart_Urlencode(PREASON_FOR_CESSATION);
ELSIF PSCENARIO_TYPE='CANCEL_OWN' THEN
--Fetch the URL for cancel own from standing data.
BEGIN
SELECT VALUE
INTO v_url
FROM SMT_ORACLE_PARAMETERS
WHERE parameter_code = c_url_cancelown
AND host_id = ( SELECT host_id
FROM SMART_HOSTS A
WHERE EXISTS ( SELECT 1
FROM DB_PARAMETERS b
WHERE A.hostname = b.hostname
AND A.database_id = b.database_id));
--handle unforseen exception
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_url := 'Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_cancelown_details'; --After testing the same, URL will be fetched from the Query
WHEN OTHERS THEN
v_url := 'Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_cancelown_details'; --After testing the same, URL will be fetched from the Query
END;
--construct the URL
v_url := v_url || '?';
v_url := v_url || 'p_data_entered=' ||Smart_Urlencode('xmloverhttp')|| '&';
v_url := v_url || 'p_channel_type=' ||Smart_Urlencode(PCHANNEL_TYPE)|| '&';
v_url := v_url || 'p_css_start_order_no=' ||Smart_Urlencode(PCSS_ORDER_NUMBER)|| '&';
v_url := v_url || 'p_tel_no=' ||Smart_Urlencode(PTELEPHONE_NUMBER)|| '&';
v_url := v_url || 'p_cancel_reason=' ||Smart_Urlencode(PCANCELLATION_REASON)|| '&';
v_url:= v_url || 'p_cancel_notes=' ||Smart_Urlencode(PCANCELLATION_NOTES);
ELSIF PSCENARIO_TYPE='CANCEL_OTHER' THEN
--Fetch the URL for cancel own from standing data.
BEGIN
SELECT VALUE
INTO v_url
FROM SMT_ORACLE_PARAMETERS
WHERE parameter_code = c_url_cancelother
AND host_id = ( SELECT host_id
FROM SMART_HOSTS A
WHERE EXISTS ( SELECT 1
FROM DB_PARAMETERS b
WHERE A.hostname = b.hostname
AND A.database_id = b.database_id));
--handle unforseen exception
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_url := 'Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_cancelother_details'; --After testing the same, URL will be fetched from the Query
WHEN OTHERS THEN
v_url := 'Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_cancelother_details'; --After testing the same, URL will be fetched from the Query
END;
--construct the URL
v_url := v_url || '?';
v_url := v_url || 'p_data_entered=' ||Smart_Urlencode('xmloverhttp')|| '&';
v_url := v_url || 'p_channel_type=' ||Smart_Urlencode(PCHANNEL_TYPE)|| '&';
v_url := v_url || 'p_css_stop_order_no=' ||Smart_Urlencode(PCSS_ORDER_NUMBER)|| '&';
v_url := v_url || 'p_tel_no=' ||Smart_Urlencode(PTELEPHONE_NUMBER)|| '&';
v_url := v_url || 'p_cancel_reason=' ||Smart_Urlencode(PCANCELLATION_REASON);
ELSIF Pscenario_type='AMEND_CRD' THEN
--Fetch the URL for cancel own from standing data.
BEGIN
SELECT VALUE
INTO v_url
FROM SMT_ORACLE_PARAMETERS
WHERE parameter_code = c_url_amendcrd
AND host_id = ( SELECT host_id
FROM SMART_HOSTS A
WHERE EXISTS ( SELECT 1
FROM DB_PARAMETERS b
WHERE A.hostname = b.hostname
AND A.database_id = b.database_id));
--handle unforseen exception
EXCEPTION
WHEN NO_DATA_FOUND THEN
v_url := 'Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_amendcrd_details'; -- After testing the same , URL will be fetched from the Query
WHEN OTHERS THEN
v_url := 'Http://wls.brassi1c.devenv1.bt.co.uk:64738/pls/spgenv/spg_btrc.add_btrc_amendcrd_details'; -- After testing the same , URL will be fetched from the Query
END;
--construct the URL
v_url := v_url || '?';
v_url := v_url || 'p_data_entered=' ||Smart_Urlencode('xmloverhttp')|| '&';
v_url := v_url || 'p_channel_type=' ||Smart_Urlencode(PCHANNEL_TYPE)|| '&';
v_url := v_url || 'p_css_start_order_no=' ||Smart_Urlencode(PCSS_ORDER_NUMBER)|| '&';
v_url := v_url || 'p_tel_no=' ||Smart_Urlencode(PTELEPHONE_NUMBER)|| '&';
v_url := v_url || 'p_crd=' ||Smart_Urlencode(PCUSTOMER_REQUIRED_DATE)|| '&';
v_url := v_url || 'p_css_change_order_numbers='||Smart_Urlencode(PCANCELLATION_REASON);
END IF;
--this is start of setting parameters for utl http object. the show begins...
utl_http.set_transfer_timeout(v_timeout);
--Set the wallet
--XXXXX e.g.UTL_HTTP.SET_WALLET(?file:DirectoryPath?,'put password here?);
--Set proxy
--YYYYY e.g. utl_http.set_proxy(p_proxy_in, p_no_proxy_domains_in);
v_url := REPLACE(v_url,'%27%27','%27'); -- Fix to ensure Double Quotes are converted to Single Quotes
--set the required URL to utl http.
v_req := utl_http.begin_request(v_url);
--Authentication setting
--Fetch the user id and password from stnding data.
BEGIN
SELECT *
INTO v_userid_pwd
FROM SMT_ORACLE_PARAMETERS
WHERE PARAMETER_CODE=c_spg_useridpwd
AND HOST_ID = ( SELECT HOST_ID
FROM SMART_HOSTS A
WHERE EXISTS ( SELECT 1
FROM DB_PARAMETERS B
WHERE A.HOSTNAME = B.HOSTNAME
AND A.DATABASE_ID = B.DATABASE_ID));
EXCEPTION
WHEN NO_DATA_FOUND THEN
P_RESPONSE := 'ORACLE_ERROR: USER id AND Password NOT configured IN SMT_ORACLE_PARAMETERS:SPGIDPWD';
WHEN OTHERS THEN
P_RESPONSE := 'ORACLE_ERROR: USER id AND Password NOT configured IN SMT_ORACLE_PARAMETERS:SPGIDPWD';
END;
--utl_http.set_authentication(v_req, p_username_in, p_password_in);
utl_http.set_authentication(v_req, v_userid_pwd.description, v_userid_pwd.VALUE);
v_resp := utl_http.get_response(v_req);
--Fill in the the response time
PRESPONSE_TIME := (DBMS_UTILITY.GET_TIME - v_start_time)/100;
IF v_resp.reason_phrase = 'OK' THEN
-- Fetch the response
BEGIN
LOOP
utl_http.read_line(v_resp, v_buffer);
P_RESPONSE := P_RESPONSE || v_buffer;
END LOOP;
utl_http.end_response(v_resp);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(v_resp);
P_RESPONSE := P_RESPONSE || v_buffer;
END;
ELSIF v_resp.reason_phrase <> 'OK' OR P_RESPONSE = '' THEN
--error handling starts
--If the HTTP Status is not OK then store the error information
PORACLE_ERROR_MESSAGE := 'Status Code: '|| v_resp.STATUS_CODE||'. Reason Phrase ' ||v_resp.reason_phrase;
P_RESPONSE := 'ORACLE_ERROR: '|| ' Reason Phrase ' || v_resp.reason_phrase;
PORACLE_ERROR := v_resp.STATUS_CODE;
END IF;
--In case we got successful response from SPG
IF P_RESPONSE LIKE '%<RetCde>0</RetCde>%' THEN
PDATA_TRANSFER_STATUS := 'Y';
ELSE
BEGIN
SELECT message
INTO vl_std_returnCode
FROM SMT_MESSAGES
WHERE MESSAGE_CODE='SPGANTIDTS';
EXCEPTION
WHEN NO_DATA_FOUND THEN
vl_std_returnCode := '-12545,-29273,-1,401,';
WHEN OTHERS THEN
vl_std_returnCode := '-12545,-29273,-1,401,';
END;
--In case there was an error do not update Data Transfer Status
IF PORACLE_ERROR <> NULL AND INSTR(vl_std_returnCode, PORACLE_ERROR || ',', 1, 1) <> 0 THEN
PDATA_TRANSFER_STATUS:=PDATA_TRANSFER_STATUS;
ELSE
vl_RetCode := SUBSTR(P_RESPONSE, INSTR(P_RESPONSE,'<RetCde>', 1, 1),
INSTR(P_RESPONSE,'</RetCde>',1,1)+9 - INSTR(P_RESPONSE,'<RetCde>', 1, 1));
BEGIN
SELECT VALUE
INTO vl_std_returnCode
FROM SMT_ORACLE_PARAMETERS
WHERE PARAMETER_CODE='SPGRCS'
AND HOST_ID = ( SELECT HOST_ID
FROM SMART_HOSTS A
WHERE EXISTS ( SELECT 1
FROM DB_PARAMETERS B
WHERE A.HOSTNAME = B.HOSTNAME
AND A.DATABASE_ID = B.DATABASE_ID));
EXCEPTION
WHEN NO_DATA_FOUND THEN
vl_std_returnCode := '<RetCde>4244</RetCde><RetCde>4245</RetCde><RetCde>4246</RetCde>';
WHEN OTHERS THEN
vl_std_returnCode := '<RetCde>4244</RetCde><RetCde>4245</RetCde><RetCde>4246</RetCde>';
END;
IF INSTR(vl_std_returnCode, vl_RetCode, 1, 1) <> 0 THEN
--needs not to re attempted.
PDATA_TRANSFER_STATUS:='X';
ELSE
--In case we did'nt got SUCCESSFUL response FROM SPG THEN UPDATE the Data Transfer Status so that the failed requests can be picked up BY the NEXT batch job RUN
IF PDATA_TRANSFER_STATUS='N' THEN
--initially if data transfer status was N then update it now to F
PDATA_TRANSFER_STATUS := 'F';
ELSIF PDATA_TRANSFER_STATUS='F' THEN
--initially if data transfer status was N then update it now to S
PDATA_TRANSFER_STATUS := 'S';
END IF;
END IF;
END IF;
END IF;
--Now Update all the modified Values
UPDATE SPG_INTERFACE_TABLE
SET response = P_RESPONSE,
data_transfer_status = PDATA_TRANSFER_STATUS,
oracle_error = PORACLE_ERROR,
oracle_error_message = PORACLE_ERROR_MESSAGE,
response_time = PRESPONSE_TIME
WHERE transaction_id = PTRANSACTION_ID;
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
--Handling the unhandled exception
PORACLE_ERROR := SQLCODE;
PORACLE_ERROR_MESSAGE := SQLERRM;
P_RESPONSE := 'ORACLE_ERROR: '|| PORACLE_ERROR_MESSAGE;
PRESPONSE_TIME := (DBMS_UTILITY.GET_TIME - v_start_time)/100;
SELECT data_transfer_status INTO PDATA_TRANSFER_STATUS
FROM SPG_INTERFACE_TABLE
WHERE transaction_id=PTRANSACTION_ID;
--New functionality to update the oracle error and oracle error message and not the Data Transfer Status
BEGIN
SELECT message
INTO vl_std_returnCode
FROM SMT_MESSAGES
WHERE MESSAGE_CODE='SPGANTIDTS';
EXCEPTION
WHEN NO_DATA_FOUND THEN
vl_std_returnCode := '-12545,-29273,-1,';
WHEN OTHERS THEN
vl_std_returnCode := '-12545,-29273,-1,';
END;
vl_RetCode := PORACLE_ERROR || ',';
IF INSTR(vl_std_returnCode, vl_RetCode, 1, 1) <> 0 THEN
--If the error is found in above maintained standing data do not change the Data Transfer Status
pdata_transfer_status:=pdata_transfer_status;
ELSE
IF pdata_transfer_status='N' THEN
PDATA_TRANSFER_STATUS := 'F';
DBMS_OUTPUT.PUT_LINE('DUE TO ERROR DATA COULDN''T GET TRANSFERED TO SPG FOR TRANSACTION'||' '||PTRANSACTION_ID);
DBMS_OUTPUT.PUT_LINE(SQLERRM);
ELSIF pdata_transfer_status='F' THEN
PDATA_TRANSFER_STATUS := 'S';
DBMS_OUTPUT.PUT_LINE('DUE TO ERROR DATA COULDN''T GET TRANSFERED TO SPG FOR TRANSACTION'||' '||PTRANSACTION_ID);
DBMS_OUTPUT.PUT_LINE(SQLERRM);
ELSE
DBMS_OUTPUT.PUT_LINE('Failure WHEN sending data TO Error LOG. Data Transfer Status IS ' || PDATA_TRANSFER_STATUS || '. TRANSACTION ID '|| PTRANSACTION_ID);
END IF;
END IF;
--Now update all the information gathered above to the table
UPDATE SPG_INTERFACE_TABLE
SET response = P_RESPONSE,
data_transfer_status = PDATA_TRANSFER_STATUS,
oracle_error = PORACLE_ERROR,
oracle_error_message = PORACLE_ERROR_MESSAGE,
response_time = PRESPONSE_TIME
WHERE transaction_id = PTRANSACTION_ID;
COMMIT;
END;
/I have fixed the problem by own.
Seems there are some while space in the endpoint url.
Fix
http_req:= utl_http.begin_request
trim(l_endpoint_url)
,'POST'
,'HTTP/1.1'
It works...
Regards
BS -
User Authentication for subfolder not working in Web Browser
We are using Oracle Application Server 10.1.2.3 and Database Server 10.2.0.5 for our application.
One of the functionalities of the Application is to send emails with attachments.
The logic is that the Application would generate the attachment file on the Application Server.
Then a database package uses Oracle's utl_http package/procedures(more specifically utl_http.request_pieces where the single argument is a URL) to pick up the file from the Application Server via URL, attach the file and send the email.
Exchange and Relay Server is also set in the Application.
The problem is that the folder containing the folder which stores the attachments is having user authentication set.
Example : The main folder is /apps/interface, this folder requires a valid user when it is accessed via URL on a web browser.
Alias created in httpd.conf
Alias /int-dir/ "/apps/interface/"
The folder /apps/interface/email/ is the folder where the attachment files are generated and stored.
Application Server : 10.12.213.21
Database Server : 10.12.213.22
Email Server : 10.12.213.44
Configuration as per httpd.conf
Alias /int-dir/ "/apps/interface/"
<Location /int-dir/>
AuthName "Interface folder"
AuthType Basic
AuthUserFile "/u01/app/oracle/as10g/oasmid/Apache/Apache/conf/.htpasswd"
require user scott
</Location>
<Location /int-dir/email>
Options Indexes Multiviews IncludesNoExec
Order deny,allow
Deny from all
Allow from 10.12.213.21
Allow from 10.12.213.22
Allow from 10.12.213.44
</Location>
Using the above configuration the Application is able to attach the files and send the email, however, when we access the following URL :
http://10.12.213.21:7778/int-dir/ - it prompts for user authentication
However if we use the following URL :
http://10.12.213.21:7778/int-dir/email/ - it does not prompt for user authentication, and all the files in the folder are displayed in the browser.
I have tried so many things including AllowOverride, .htaccess, but i am not able to get user authentication for the email folder.
Please help me if you can.
Thanking you in advance,
GLad to give any more information that i can.
dxbrockyThanks for your response. I fixed the problem by selecting "full site" or "full website" at bottom of the web page. After making this selection the zoom function returned. Thanks again for your interest.
-
Error invoking SSL web service using pl sql UTL_HTTP
Web Services Gurus,
I am invoking a secure web service based on the following WSDL file from a pl/sql program using UTL_HTTP package.
The web service is secure and prompts for authentication.
The web services certificate is imported in Oracle Wallet on Database Server.
I am listing the WSDL file, the pl/sql code and error message as follows -
1. The WSDL file -
<definitions
name="Webservice"
targetNamespace="http://webservice.airclic.com/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://webservice.airclic.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<types>
<xs:schema targetNamespace="http://webservice.airclic.com/" version="1.0" xmlns:tns="http://webservice.airclic.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Exception" type="tns:Exception"/>
<xs:element name="sendAuthenticationResponse" type="tns:sendAuthenticationResponse"/>
<xs:element name="sendAuthenticationResponseResponse" type="tns:sendAuthenticationResponseResponse"/>
<xs:complexType name="AuthenticationResponse">
<xs:complexContent>
<xs:extension base="tns:Response">
<xs:sequence>
<xs:element name="success" type="xs:boolean"/>
<xs:element name="username" type="xs:string"/>
<xs:element minOccurs="0" name="password" type="xs:string"/>
<xs:element minOccurs="0" name="firstName" type="xs:string"/>
<xs:element minOccurs="0" name="lastName" type="xs:string"/>
<xs:element minOccurs="0" name="email" type="xs:string"/>
<xs:element minOccurs="0" name="active" type="xs:boolean"/>
<xs:element minOccurs="0" name="timeZone" type="xs:string"/>
<xs:element minOccurs="0" name="group" type="xs:string"/>
<xs:element minOccurs="0" name="role" type="xs:string"/>
<xs:element minOccurs="0" name="errorCode" type="xs:string"/>
<xs:element minOccurs="0" name="errorMessage" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DispatchEvent"></xs:complexType>
<xs:complexType name="sendAuthenticationResponse">
<xs:sequence>
<xs:element minOccurs="0" name="authenticationResponse" type="tns:AuthenticationResponse"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="sendAuthenticationResponseResponse">
<xs:sequence/>
</xs:complexType>
<xs:simpleType name="status"></xs:simpleType>
<xs:simpleType name="source"></xs:simpleType>
<xs:simpleType name="eventType"></xs:simpleType>
</xs:schema>
</types>
<message name="Webservice_sendAuthenticationResponse">
<part name="sendAuthenticationResponse" element="tns:sendAuthenticationResponse"/>
</message>
<message name="Webservice_sendAuthenticationResponseResponse">
<part name="sendAuthenticationResponseResponse" element="tns:sendAuthenticationResponseResponse"/>
</message>
<portType name="Webservice">
<operation name="sendAuthenticationResponse" parameterOrder="sendAuthenticationResponse">
<input message="tns:Webservice_sendAuthenticationResponse"/>
<output message="tns:Webservice_sendAuthenticationResponseResponse"/>
<fault name="Exception" message="tns:Exception"/>
</operation>
</portType>
<binding name="WebserviceBinding" type="tns:Webservice">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sendAuthenticationResponse">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="Exception">
<soap:fault name="Exception" use="literal"/>
</fault>
</operation>
</binding>
<service name="Webservice">
<port name="WebservicePort" binding="tns:WebserviceBinding">
<soap:address location="https://host.airclic.com:443/webservice/product/fieldservice/v1/Webservice"/>
</port>
</service>
</definitions>
2. The pl/sql code that calls the web service operation sendAuthenticationResponse
procedure send_auth_response
as
soap_request varchar2(30000);
soap_respond varchar2(30000);
http_req utl_http.req;
http_resp utl_http.resp;
resp XMLType;
i integer;
begin
-- initiate wallet for AirClic certificate
dbms_output.put_line ('1');
utl_http.set_wallet('file:/etc/oracle/wallet','<wallet password>');
-- create soap request
dbms_output.put_line ('2');
soap_request:= '<?xml version = "1.0" encoding = "UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:sendAuthenticationResponse xmlns="https://host.airclic.com:443/webservice/product/fieldservice/v1/Webservice" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<success xsi:type="xsd:boolean">true</success>
<username xsi:type="xsd:string">changlanih</username>
<password xsi:type="xsd:string">abcd1234</password>
<firstName xsi:type="xsd:string">hero</firstName>
<lastName xsi:type="xsd:string">changlani</lastName>
<email xsi:type="xsd:string">[email protected]</email>
<active xsi:type="xsd:boolean">true</active>
<timeZone xsi:type="xsd:string">eastern</timeZone>
<group xsi:type="xsd:string">Northeast</group>
<role xsi:type="xsd:string">Service Manager</role>
<errorCode xsi:type="xsd:string"></errorCode>
<errorMessage xsi:type="xsd:string"></errorMessage>
</ns1:sendAuthenticationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
-- request that exceptions are raised for error Status Codes
dbms_output.put_line ('3');
utl_http.set_response_error_check (true);
-- allow testing for exceptions like UTL_HTTP.http_server_error
dbms_output.put_line ('4');
utl_http.set_detailed_excp_support (true);
--utl_http.set_transfer_timeout (ln_time_out);
dbms_output.put_line ('5');
utl_http.set_body_charset ('UTF-8');
-- begin request
dbms_output.put_line ('5.5');
http_req:= utl_http.begin_request
('https://host.airclic.com:443/webservice/product/fieldservice/v1/Webservice/sendAuthenticationResponse', ------ is the url correct here ?
'POST',
'HTTP/1.1'
dbms_output.put_line ('6');
utl_http.set_authentication(http_req, '<username for webservice>', '<password for webservice user>');
dbms_output.put_line ('7');
utl_http.set_persistent_conn_support (http_req, false);
dbms_output.put_line ('8');
utl_http.set_header(http_req, 'Content-Type', 'text/xml'); -- since we are dealing with plain text in XML documents
dbms_output.put_line ('9');
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
dbms_output.put_line ('10');
utl_http.set_header(http_req, 'SOAPAction', ''); -- required to specify this is a SOAP communication
dbms_output.put_line ('11');
utl_http.write_text(http_req, soap_request);
dbms_output.put_line ('12');
http_resp := utl_http.get_response(http_req);
-- debug messages
DBMS_OUTPUT.PUT_LINE('-------utl_http.get_response---------------------');
DBMS_OUTPUT.PUT_LINE('http_resp.status_code is :'||http_resp.status_code );
DBMS_OUTPUT.PUT_LINE('http_resp.reason_phrase is :'||http_resp.reason_phrase);
DBMS_OUTPUT.PUT_LINE('http_resp.http_version is :'||http_resp.http_version);
DBMS_OUTPUT.PUT_LINE('http_resp.private_hndl is :'||http_resp.private_hndl);
DBMS_OUTPUT.PUT_LINE('-------utl_http.get_response----------------------');
utl_http.read_text(http_resp, soap_respond);
dbms_output.put_line ('13');
utl_http.end_response(http_resp);
dbms_output.put_line ('14');
resp := XMLType.createXML(soap_respond);
dbms_output.put_line ('15');
resp := resp.extract('/soap:Envelop/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
i:=0;
dbms_output.put_line ('16');
loop
dbms_output.put_line(substr(soap_respond, 1 + i * 255, 250));
i := i + 1;
if (i * 250) > length(soap_respond) then
exit;
end if;
end loop;
exception
when utl_http.request_failed then
dbms_output.put_line('request failed: ' || utl_http.get_detailed_sqlerrm);
when utl_http.http_server_error then
dbms_output.put_line('server error: ' || utl_http.get_detailed_sqlerrm);
when utl_http.http_client_error then
dbms_output.put_line('client error: ' || utl_http.get_detailed_sqlerrm);
when others then
dbms_output.put_line(sqlerrm);
end send_auth_response;
3. Output when I run the send_auth_response procedure
Connecting to the database cpdev.
1
2
3
4
5
5.5
ORA-12560: TNS:protocol adapter error
Process exited.
Disconnecting from the database cpdev.
Comments -
The web service operation only has input message. The input message consists of a complex type as seen in WSDL.
Questions -
1. This is my first attempt in invoking a web service from pl/sql program. Is the code in SOAP body correct as mapped to the complex type in WSDL ?
2. As seen from the dbms_out - the last message before ORA-12560 is 5.5, that means the call is erroring at following code line -
http_req:= utl_http.begin_request ------ what am I doing wrong here ?
3. The web service is SSL as seen from WSDLand needs a username/password for access - which is being performed by following code line -
utl_http.set_authentication(http_req, '<username for webservice>', '<password for webservice user>'); ------- is that correct ?
4. I am not using any proxy server - should I be using it ? When is it necessary to use proxy ?
Appreciate any help.
Thanx.Oracle is hosted by HOST A - this is where the pl/sql program resides.
The Web Service being accessed by pl/sql program is hosted by HOST B and there are 4 firewalls in between.
Oracle was not even able to establish connection to web services host.
Escalated the issue with networking folks and they resolved the connectivity problem.
Hope that helps. -
Error using UTL_HTTP over HTTPS
Hello,
I am trying to simply connect to an HTTPS web site. I used this query to test the connection :
select utl_http.request('https://subdomain.maindomain.com/webservice.wsdl',null, 'file:C:\MyWalletDirectory','WalletPassword') from dual;
and I always got the following error :
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1577
ORA-29268: HTTP client error
ORA-06512: at line 1
Can anybody help me with this issue ? Is it possible to have a more meaningfull message ?
Thanks...
LIBI've written a basic PL/SQL web browser template. It looks/works as follows:
SQL> select * from TABLE( webbrowser('https://metalink.oracle.com') ) where rownum < 11;
COLUMN_VALUE
Setting browser configuration
Wallet set to file:/etc/ORACLE/WALLETS/oracle/
Proxy Server is 198.54.206.99
Proxy URL modified to include proxy user name and password
Proxy URL is http://verreyb:*****@198.54.206.99
HTTP: GET https://metalink.oracle.com
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Welcome to Oracle MetaLink</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><LINK
href="oracle.htm" rel=stylesheet>
10 rows selected.
The source code:
create or replace type TStrings is table of varchar2(4000);
create or replace function WebBrowser( url varchar2 ) return TStrings pipelined is
-- BASIC PL/SQL WEB BROWSER TEMPLATE
-- supports http, https and proxy servers
-- fixed constants
C_NO_PROXY_FOR constant varchar2(4000) := 'localhost';
C_WALLET constant varchar2(4000) := 'file:/etc/ORACLE/WALLETS/oracle/';
C_WALLET_PASS constant varchar2(4000) := '<wallet password goes here>';
-- Proxy settings that can be made arguments in the WebBrowser() call
proxyServer varchar2(20) := '198.54.206.99';
-- not all proxy servers use authentication, but many corporate proxies do, in
-- which case you need to specify your auth details here
-- (make it nulls if not applicable)
proxyUser varchar2(50) := '<proxy username goes here>';
proxyPass varchar2(50) := '<proxy password goes here>';
-- our local variables
proxyURL varchar2(4000);
request UTL_HTTP.req;
response UTL_HTTP.resp;
buffer varchar2(4000);
endLoop boolean;
begin
-- our "browser" settings
PIPE ROW( 'Setting browser configuration' );
UTL_HTTP.set_response_error_check( TRUE );
UTL_HTTP.set_detailed_excp_support( TRUE );
UTL_HTTP.set_cookie_support( TRUE );
UTL_HTTP.set_transfer_timeout( 30 );
UTL_HTTP.set_follow_redirect( 3 );
UTL_HTTP.set_persistent_conn_support( TRUE );
-- set wallet for HTTPS access
PIPE ROW( 'Wallet set to '||C_WALLET );
UTL_HTTP.set_wallet( C_WALLET, C_WALLET_PASS );
-- configure for proxy access
if proxyServer is not NULL then
PIPE ROW( 'Proxy Server is '||proxyServer );
proxyURL := 'http://'||proxyServer;
if (proxyUser is not NULL) and (proxyPass is not NULL) then
proxyURL := REPLACE( proxyURL, 'http://', 'http://'||proxyUser||':'||proxyPass||'@' );
PIPE ROW( 'Proxy URL modified to include proxy user name and password' );
end if;
PIPE ROW( 'Proxy URL is '|| REPLACE(proxyURL,proxyPass,'*****') );
UTL_HTTP.set_proxy( proxyURL, C_NO_PROXY_FOR );
end if;
PIPE ROW( 'HTTP: GET '||url );
request := UTL_HTTP.begin_request( url, 'GET', UTL_HTTP.HTTP_VERSION_1_1 );
-- set HTTP header for the GET
UTL_HTTP.set_header( request, 'User-Agent', 'Mozilla/4.0 (compatible)' );
-- get response to the GET from web server
response := UTL_HTTP.get_response( request );
-- pipe the response as rows
endLoop := false;
loop
exit when endLoop;
begin
UTL_HTTP.read_line( response, buffer, TRUE );
if (buffer is not null) and length(buffer)>0 then
PIPE ROW( buffer );
end if;
exception when UTL_HTTP.END_OF_BODY then
endLoop := true;
end;
end loop;
UTL_HTTP.end_response( response );
return;
exception when OTHERS then
PIPE ROW( SQLERRM );
end;
show errorsEdited by: Billy Verreynne on Sep 4, 2008 7:47 AM (old forum tags poorly supported by new Jive forum s/w) -
I have a PLSQL program that performs an HTTP POST to fetch data from an external website. The website is returning the contents of a file in the HTTP response. This program has been working for years and just started giving us trouble recently at a particular client. The issue cannot be reproduced locally, only on a specific client machine when trying to download a particular set of XML files through this HTTP interface.
The stack trace is:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1336
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.UTL_HTTP", line 1336The code in question is:
PROCEDURE SEND_REQUEST
p_REQUEST IN CLOB,
p_RESPONSE OUT CLOB,
p_HEADERNAMES OUT STRING_COLLECTION,
p_HEADERVALUES OUT STRING_COLLECTION,
p_ERRORMESSAGE OUT VARCHAR2
) IS
v_HTTP_REQ UTL_HTTP.REQ;
v_HTTP_RESP UTL_HTTP.RESP;
v_REQUEST_LEN NUMBER;
v_POS NUMBER;
v_COUNT NUMBER;
v_TEXT VARCHAR2(8192);
v_LEN NUMBER;
BEGIN
-- raise Request_Failed error if an HTTP error occurs
UTL_HTTP.SET_RESPONSE_ERROR_CHECK(TRUE);
UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(FALSE);
-- extend timeout to 10 minutes
UTL_HTTP.SET_TRANSFER_TIMEOUT(60 * 10);
v_HTTP_REQ := UTL_HTTP.BEGIN_REQUEST(G_URL, 'POST');
-- disable cookies for this request
UTL_HTTP.SET_COOKIE_SUPPORT(v_HTTP_REQ, FALSE);
-- authentication
IF g_USERNAME IS NOT NULL THEN
UTL_HTTP.SET_AUTHENTICATION(v_HTTP_REQ, g_USERNAME, g_PASSWORD);
END IF;
-- upload request body
v_REQUEST_LEN := DBMS_LOB.GETLENGTH(p_REQUEST);
UTL_HTTP.SET_HEADER(v_HTTP_REQ, 'Content-Type', 'application/x-www-form-urlencoded');
UTL_HTTP.SET_HEADER(v_HTTP_REQ, 'Content-Length', v_REQUEST_LEN);
-- write the CLOB request data
v_POS := 1;
WHILE v_POS <= v_REQUEST_LEN LOOP
v_LEN := 8192;
DBMS_LOB.READ(p_REQUEST, v_LEN, v_POS, v_TEXT);
UTL_HTTP.WRITE_TEXT(v_HTTP_REQ, v_TEXT);
v_POS := v_POS + v_LEN;
END LOOP;
-- get the response
v_HTTP_RESP := UTL_HTTP.GET_RESPONSE(v_HTTP_REQ);
-- read it into CLOB
DBMS_LOB.CREATETEMPORARY(p_RESPONSE, TRUE);
DBMS_LOB.OPEN(p_RESPONSE, DBMS_LOB.LOB_READWRITE);
LOOP
BEGIN
UTL_HTTP.READ_TEXT(v_HTTP_RESP, v_TEXT, 8192);
EXCEPTION
WHEN UTL_HTTP.END_OF_BODY THEN
ERRS.LOG_AND_CONTINUE('Send_Request: Exeception occurred reading text from the http response.',
p_LOG_LEVEL => LOGS.C_LEVEL_INFO_MORE_DETAIL);
v_TEXT := '';
END;
EXIT WHEN NVL(LENGTH(v_TEXT), 0) = 0;
DBMS_LOB.WRITEAPPEND(p_RESPONSE, LENGTH(v_TEXT), v_TEXT);
END LOOP;
DBMS_LOB.CLOSE(p_RESPONSE);
-- gather response headers
p_HEADERNAMES := STRING_COLLECTION();
p_HEADERVALUES := STRING_COLLECTION();
v_COUNT := UTL_HTTP.GET_HEADER_COUNT(v_HTTP_RESP);
v_POS := 1;
WHILE v_POS <= v_COUNT LOOP
p_HEADERNAMES.EXTEND();
p_HEADERVALUES.EXTEND();
UTL_HTTP.GET_HEADER(v_HTTP_RESP, v_POS, p_HEADERNAMES(p_HEADERNAMES.LAST), p_HEADERVALUES(p_HEADERVALUES.LAST));
v_POS := v_POS + 1;
END LOOP;
UTL_HTTP.END_RESPONSE(v_HTTP_RESP);
-- success!
p_ERRORMESSAGE := NULL;
EXCEPTION
WHEN UTL_HTTP.REQUEST_FAILED THEN
ERRS.LOG_AND_CONTINUE('Send_Request: Exeception Request Failed caught.', p_LOG_LEVEL => LOGS.C_LEVEL_INFO_MORE_DETAIL);
WHEN OTHERS THEN
ERRS.LOG_AND_CONTINUE('Send_Request: Exeception Others caught.', p_LOG_LEVEL => LOGS.C_LEVEL_INFO_MORE_DETAIL);
END SEND_REQUEST;It fails specifically at the section that is reading text from the response:
UTL_HTTP.READ_TEXT(v_HTTP_RESP, v_TEXT, 8192);
...Any thoughts?
I have used a packet sniffer, Wireshark, to monitor the HTTP traffic between the website and database during the issue. There is nothing malformed with the Response content. No special chars that I can find. Etc.
The machine in question that is failing is running 10gR2.
I have done some searching and I found this forum post:
utl_http.read_text and multi-byte support
and this Oracle bug:
https://support.oracle.com/CSP/main/article?cmd=show&type=BUG&id=4015165&productFamily=Oracle
Not really much help.
Any help would be appreciated.
Thanks,
GatorPaul
Edited by: 939368 on Jun 7, 2012 2:27 PMIn this case, and most cases, the NLS_LENGTH_SEMANTICS is set to 'BYTE'. Realize that this is an Oracle application that we deploy into an external customer environment and we do not always have the ability to control NLS Settings.
So, based on your explanation, I would expect that an approach like this would fix it:
v_TEXT VARCHAR2(32766);
UTL_HTTP.READ_TEXT(v_HTTP_RESP, v_TEXT, 8192);
Here we are saying, get the next 8192 characters, but put that into a buffer that allows up to 32K bytes. This should allow for the enough room for up to 4 bytes per character. Am I understanding you correctly?
But here is my question:
I put a fix in place today, where I increased both the v_TEXT byte size and the GET_TEXT 'len' parameter to 32766 and it fixed the issue. By doing that, I am telling it: Give me the next 32766 characters and put it into a VARCHAR2(32766). Given your explanation, I would expect this to overflow the v_TEXT variable as well, or at least have the potential to do so.
We were processing 5 different XML responses. They were all failing originally. After the change, they all passed. Their sizes were 47K, 21K, 14K, 48K, and 21K. If the XML file was small, < 32K then maybe is slipped under the radar given the new buffer size of 32766. But what about the 2 files that were over 32K. Very curious on your thoughts. I did not have a loop counter in there to see how many times it was looping to parse the 48K file. With a new buffer size of 32K I would expect it to loop 2x. But, I know in this case, the file was streamed over the network using 14 smaller TCP packets, none of which were more than 9000 bytes. Maybe the PLSQL looped 14 times as well.
When the process was failing for all 5 files, I do know at that time it was always failing on the first loop (first 8192 characters).
Anyway, Thanks for the advice. I will let you guys know if I uncover anymore info.
G8torPaul
Edited by: G8torPaul on Jun 12, 2012 2:04 PM
Edited by: G8torPaul on Jun 12, 2012 2:04 PM
Edited by: G8torPaul on Jun 12, 2012 2:05 PM -
URGENT: Content Services using PL/sql utl_http
I'm using Oracle Collaboration Suite Content Services Version 10.1.2.0.0 (Oracle 10g Enterprise Edition Release 10.1.0.4.0).
Using PL/sql, I want to be able to retrieve a html document stored in a folder in Content Services, and store the contents of that document in a table.
I can retrieve and store the contents of the document if it stored anywhere - I just can't when the document resides in Content Services.
Within PL/sql I am authenticating using utl_http.set_authentication, then using utl_http.request_pieces.
I'm not getting an error message, just the "<" character stored in my table.
Can I not use utl_http.request_pieces for retrieving a document in Content Services?
Thanks
PaulHI Michiel
I am also trying to achieve something similar to that. I am trying to call a web service that sends an xml attachment over MTOM? Kindly, let me know if this was achievable from your end? I mean how did the issue got resolved.
thanks
vijay -
UTL_HTTP and client certificate request
I am hoping that someone can help me. We have a web site that we need to hit and pull the html code back from the pages and we have the code to get what we need but the website now has an option where it requests a client certificate from a user for authentication or if you cancel the request it will then ask you for username and password. I cannot figure out how to submit a cancel on the client certificate request so that my application can submit the username and password authentication. Does anyone have an idea or example to do this? Also if you submit a bad certificate it will prompt you for authentication. So if someone knows how to submit client certificates that would be helpful as well.
Thanks in advance.I've never faced this issue but you might want to look at using UTL_TCP rather than UTL_HTTP.
http://www.psoug.org/reference/utl_tcp.html -
9iR2 utl_http and HTTP Continue response
I'm using 9iR2 (9.2.0.1) on Win2K. I want to POST XML using https (HTTP/1.1 on SSL) to a remote business partner throught the company proxy that requires basic authentication.
Everything works fine except when I receive a response = 100 (HTTP continue) from the proxy when the link is slow.
I understand that simple HTTP Clients that implement HTTP/1.1 can discard the continue response and return the subsequent 'real' response.
Does anyone have any suggestions for how to do this with utl_http?
Thanks in advance
Sandyhi
i'm facing the same problem! has anyone solve this thing out?
and by the way i can't find the bug 2467239. would appreciate some help too.
Vitor -
Issues with utl_https, Oracle Wallet and firewall
Hello Everyone,
We are experimenting with Oracle wallet and utl_http and are attempting to do an https transfer, but we are facing some problems. I will appreciate your help greatly if you can advise on what could be wrong. We are on db version 10.2.0.1 and Unix HP-UX and are operating from within a firewall. The intention is to ping an https url and get a simple 200 response. Future development would include get/post XML documents from that url and other interesting stuff. I understand that utl_http with Oracle wallet can be used for this purpose.
The wallet has been created and the ewallet.p12 exists. We downloaded the SSL certificate from the url's website and uploaded into the wallet. Everything works if I put in a url with plain http but then things don't work with an HTTP*S* url. Is something called HTTPS TUNNELLING required because we have a firewall? I have no idea what this is or how it can be done.
I tried https with an internal urls within the firewall. But again, no luck. - So probably not just a firewall issue.
With HTTPS when I run the below code I get the following error with internal or external https sites. Again, greatly appreciate your time and help because this is the first time we are using Oracle wallet manager and do not know where to go from here.
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1029
ORA-29268: HTTP client error
declare
url varchar2(225);
req utl_http.req;
resp utl_http.resp;
my_proxy BOOLEAN;
name varchar2(2000);
value varchar2(2000);
V_proxy VARCHAR2(2000);
v_n_proxy varchar2(2000);
v_msg varchar2(100);
v_len PLS_INTEGER := 1000;
BEGIN
-- Turn off checking of status code.
utl_http.set_response_error_check(FALSE);
--Set proxy server
utl_http.set_proxy('my-proxy');
utl_http.set_wallet('file:<full Unix path to the wallet on DB server>','wallet998');
req := utl_http.begin_request('https://service.ariba.com/service/transaction/cxml.asp');
--Set proxy authentication
utl_http.set_authentication(req, 'myproxyid', 'myproxypswd','Basic',TRUE); -- Use HTTP Basic
resp := utl_http.get_response(req);
FOR i IN 1..utl_http.get_header_count(resp) LOOP
utl_http.get_header(resp, i, name, value);
dbms_output.put_line(name || ': ' || value);
END LOOP;
utl_http.end_response(resp);
exception
when others then
dbms_output.put_line(sqlerrm);
END;user11992646 wrote:
Here we have something like "firewall rules". When we want internet users to access an external website without entering web proxy userid/pswd(the same I used for set_authentication), our web team establishes a rule or an exception like ...such and such website can be accessed without entering proxy userid/pswd information. A firewall does not use user authentication - in other words, when a web browser traffic goes via a firewall, the firewall will not ask the web browser for credentials and the web browser will not popup a username & password box.
A firewall does not work at application protocol level. It works at physical wire level. IP addresses, subnets, ports, packet type and header content, and so on.
A web proxy works at application protocol level. The web browser sends the http request to the web proxy. The web proxy may expect authentication - and request the web browser to supply it. In which case the web browser will popup the authentication box for you to enter a username and password.
Thus if you are going via a plain firewall, it does not need any kind of username/password identification. It uses your IP address and other data about the packets your machine is sending, to determine what rules to apply.
The remote web site can also expect authentication (and if the web proxy does too, you have 2 sets of credentials to supply). A firewall cannot supply these credentials (as it works on a network protocol level). A web proxy (working on application protocol level) can.
When your network traffic (e.g. from UTL_HTTP) goes via a firewall, there is nothing special or specific you need to do. UTL_HTTP is an application protocol. The firewall deals with the lower level wire protocol.
Otoh, if your http/https traffic goes via a proxy, you need to do specific steps in UTL_HTTP (like setting the proxy and supplying credentials if needed).
So I'm not sure what you are saying above.. a firewall cannot supply web authentication details for web server access.
Then I commented out set_proxy, set_authentication. I was still able to establish SSL handshake with https://ihavefirewallrule.com and retrieve data. Seems like "firewall rule" took care of proxy authentication also.
Proxy authentication only applies when the proxy expects authentication. And as I mentioned, a firewall does use username authentication, and nor can supply authentication as an application protocol proxy.
Now it gets even weirder. I even commented out the set_wallet part. It still worked! I was able to establish a SSL handshake with https://ihavefirewallrule.com e.g. https://verisign.com.
In the same Oracle session? You'll need to check how wallet access is handled. I think that once opened in a session it stays open - thus subsequent code does not need to explicitly open the wallet again.
In our test instance both Apache web server and DB server are on the same machine.
Is somehow utl_http using our Apache server's SSL certificates to connect to https://ihavefirewallrule.com?
Not possible. Oracle does not know anything of such an Apache installation at a s/w level. Nor will it borrow and use anything from such installed s/w.
Would opening up 443/tcp port to firewall + proxy_authentication in the code resolve these issues? I think your comment in previous e-mail regarding port 80 and 443 hints at this.That depends on the s/w layers you have between UTL_HTPP and the remote web server - and I'm not clear whether you are using just a firewall, just a proxy, both, or a single piece of s/w that attempts to be both a wire protocol firewall and an application protocol proxy..
The best would be to talk to the network administrator on your side. As you are accessing that remote site from an Oracle server using UTL_HTTP for production purposes, it means that "trusted" server access can be configured. In such a case, opening tcp ports 443 and 80 for the server's IP on the firewall should be considered. No web proxy used. The routing table of the Oracle server setup to ensure that traffic to external sites be routed via the firewall.
Not an Oracle issue.. but simply one of network connectivity between the server platform running Oracle and the remote web sites that need to be accessed. -
I would love some help with this issue. I have configured my SharePoint foundation 2010 site to use Claims Based Auth with Certificate authentication method with ADFS 2.0 I have a test account set up with lab.acme.com to use the ACS.
When I log into my site using Windows Auth, everything is great. However when I log in and select my ACS token issuer, I get sent, to the logon page of the ADFS, after selected the ADFS method. My browser prompt me which Certificate identity I want
to use to log in and after 3-5 second
and return me the logon page with error message “Authentication failed”
I base my setup on the technet article
http://blogs.technet.com/b/speschka/archive/2010/07/30/configuring-sharepoint-2010-and-adfs-v2-end-to-end.aspx
I validated than all my certificate are valid and able to retrieve the crl
I got in eventlog id 300
The Federation Service failed to issue a token as a result of an error during processing of the WS-Trust request.
Request type: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue
Additional Data
Exception details:
Microsoft.IdentityModel.SecurityTokenService.FailedAuthenticationException: MSIS3019: Authentication failed. ---> System.IdentityModel.Tokens.SecurityTokenValidationException:
ID4070: The X.509 certificate 'CN=Me, OU=People, O=Acme., C=COM' chain building failed. The certificate that was used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode. 'A certification chain processed
correctly, but one of the CA certificates is not trusted by the policy provider.
at Microsoft.IdentityModel.X509CertificateChain.Build(X509Certificate2 certificate)
at Microsoft.IdentityModel.Tokens.X509NTAuthChainTrustValidator.Validate(X509Certificate2 certificate)
at Microsoft.IdentityModel.Tokens.X509SecurityTokenHandler.ValidateToken(SecurityToken token)
at Microsoft.IdentityModel.Tokens.SecurityTokenElement.GetSubject()
at Microsoft.IdentityServer.Service.SecurityTokenService.MSISSecurityTokenService.GetOnBehalfOfPrincipal(RequestSecurityToken request, IClaimsPrincipal callerPrincipal)
--- End of inner exception stack trace ---
at Microsoft.IdentityServer.Service.SecurityTokenService.MSISSecurityTokenService.GetOnBehalfOfPrincipal(RequestSecurityToken request, IClaimsPrincipal callerPrincipal)
at Microsoft.IdentityServer.Service.SecurityTokenService.MSISSecurityTokenService.BeginGetScope(IClaimsPrincipal principal, RequestSecurityToken request, AsyncCallback callback, Object state)
at Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.BeginIssue(IClaimsPrincipal principal, RequestSecurityToken request, AsyncCallback callback, Object state)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.DispatchRequestAsyncResult..ctor(DispatchContext dispatchContext, AsyncCallback asyncCallback, Object asyncState)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.BeginDispatchRequest(DispatchContext dispatchContext, AsyncCallback asyncCallback, Object asyncState)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.ProcessCoreAsyncResult..ctor(WSTrustServiceContract contract, DispatchContext dispatchContext, MessageVersion messageVersion, WSTrustResponseSerializer responseSerializer, WSTrustSerializationContext
serializationContext, AsyncCallback asyncCallback, Object asyncState)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceContract.BeginProcessCore(Message requestMessage, WSTrustRequestSerializer requestSerializer, WSTrustResponseSerializer responseSerializer, String requestAction, String responseAction, String
trustNamespace, AsyncCallback callback, Object state)
System.IdentityModel.Tokens.SecurityTokenValidationException: ID4070: The X.509 certificate 'CN=Me, OU=People, O=acme., C=com' chain building
failed. The certificate that was used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode. 'A certification chain processed correctly, but one of the CA certificates is not trusted by the policy provider.
at Microsoft.IdentityModel.X509CertificateChain.Build(X509Certificate2 certificate)
at Microsoft.IdentityModel.Tokens.X509NTAuthChainTrustValidator.Validate(X509Certificate2 certificate)
at Microsoft.IdentityModel.Tokens.X509SecurityTokenHandler.ValidateToken(SecurityToken token)
at Microsoft.IdentityModel.Tokens.SecurityTokenElement.GetSubject()
at Microsoft.IdentityServer.Service.SecurityTokenService.MSISSecurityTokenService.GetOnBehalfOfPrincipal(RequestSecurityToken request, IClaimsPrincipal callerPrincipal)
thx
Stef71This is perfectly correct on my case I was not adding the root properly you must add the CA and the ADFS as well, which is twice you can see below my results.
on my case was :
PS C:\Users\administrator.domain> $root = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\
cer\SP2K10\ad0001.cer")
PS C:\Users\administrator.domain> New-SPTrustedRootAuthority -Name "domain.ad0001" -Certificate $root
Certificate : [Subject]
CN=domain.AD0001CA, DC=domain, DC=com
[Issuer]
CN=domain.AD0001CA, DC=portal, DC=com
[Serial Number]
blablabla
[Not Before]
22/07/2014 11:32:05
[Not After]
22/07/2024 11:42:00
[Thumbprint]
blablabla
Name : domain.ad0001
TypeName : Microsoft.SharePoint.Administration.SPTrustedRootAuthority
DisplayName : domain.ad0001
Id : blablabla
Status : Online
Parent : SPTrustedRootAuthorityManager
Version : 17164
Properties : {}
Farm : SPFarm Name=SharePoint_Config
UpgradedPersistedProperties : {}
PS C:\Users\administrator.domain> $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\
cer\SP2K10\ADFS_Signing.cer")
PS C:\Users\administrator.domain> New-SPTrustedRootAuthority -Name "Token Signing Cert" -Certificate $cert
Certificate : [Subject]
CN=ADFS Signing - adfs.domain
[Issuer]
CN=ADFS Signing - adfs.domain
[Serial Number]
blablabla
[Not Before]
23/07/2014 07:14:03
[Not After]
23/07/2015 07:14:03
[Thumbprint]
blablabla
Name : Token Signing Cert
TypeName : Microsoft.SharePoint.Administration.SPTrustedRootAuthority
DisplayName : Token Signing Cert
Id : blablabla
Status : Online
Parent : SPTrustedRootAuthorityManager
Version : 17184
Properties : {}
Farm : SPFarm Name=SharePoint_Config
UpgradedPersistedProperties : {}
PS C:\Users\administrator.PORTAL> -
Authentication - multiple domains with multiple accounts
Dear All,
Consider an environment where a user, Joe Bloggs, has an account on two Windows domains: DOMA and DOMB. DOMA is a domain that all users in the organisation are members of. DOMB is a domain used by a smaller subset of users. The user's
machine is part of the DOMB domain.
I'd like to deploy SharePoint 2013 on DOMA and have the user, logged on to their DOMB machine, seamlessly authenticate (through IWA) with SharePoint 2013.
So far, I've thought of the following solutions:
1. Build a trust between the two domains. Possible, but the AD information in DOMA is more up-to-date than that in DOMB and I'd like to use that to populate SharePoint user profiles. Also, DOMB is likely to be deprecated in the future.
2. Use WorkPlace Join. Unfortunately, devices are running Windows 7 and WorkPlace Join only works for devices running Windows 8.
I've wondered whether it's possible to map two accounts on separate domains together so that a user on DOMB can effectively masquerade as their corresponding user on DOMA when authenticating with SharePoint, but haven't come across a way of doing this, yet.
Any ideas? Or, am I completely mad?!
Thanks in advance.1) Is your only option for seamless logon with IWA. It is not possible to map accounts "together" so-to-speak. SharePoint stores a reference to the user's SID, which must match the user making the request.
An ADFS trust might be another option, although that increases your deployment footprint and complexity.
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
Maybe you are looking for
-
Timeline playing back very choppy over multiformat video.
Hi Guys, I am editing some behind the scenes footage for a movie our studio is making. A lot of the media has come from different sources. Some red, some mpeg4 etc. The Mac i am using is a Quad Core Mac Pro... technically it should be powerful enough
-
Don't have Import contacts choice
Hello! I have problem with Skype to connect with Facebook. I didn't had that problem before, I had all Facebook contact in Skype and had notifications from Facebook, I don't know what happened. I have tried to add Facebook again but I can't because I
-
How can I search for a substring of a email address or a subject
... without getting hits on other fields or content. Mail 5.0 seems to have removed the ability to restrict your seach to particular fields. What you get instead is the ability to select 'people' which should be called 'addresses' or 'subjects'. T
-
Does anyone know if Motion 3 allows for EPS importing or if it still requires the creation of a PDF. Everything else about version 3 looks very cool.
-
How to monitor and handle SM35 ?
Hi, Please tell me how to monitor and error handling at SM35. how we can use this SM35 exactly? Regards, Gayathry.