ORA-29273: HTTP 请求失败,ORA-29270: 打开的 HTTP 请求太多

Posted

技术标签:

【中文标题】ORA-29273: HTTP 请求失败,ORA-29270: 打开的 HTTP 请求太多【英文标题】:ORA-29273: HTTP request failed ,ORA-29270: too many open HTTP requests 【发布时间】:2016-11-22 16:11:12 【问题描述】:
http_req := utl_http.begin_request(t_url,'POST', 

utl_http.http_version_1_1);
utl_http.set_header(http_req, 'Content-Type', t_content_type);
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header(http_req, 'SOAPAction', 'http://tempuri.org/IService/GetActive');
utl_http.write_text(http_req, soap_request);http_resp := utl_http.get_response(http_req);
Utl_Http.read_text(http_resp, response_env,32767);dbms_lob.createtemporary(x_clob, false );
bms_lob.OPEN( x_clob, dbms_lob.lob_readwrite );
BEGIN
  loop utl_http.read_text(http_resp, l_buffer); 
    dbms_lob.writeappend(x_clob, length(l_buffer) , l_buffer); 
  end LOOP;
EXCEPTION 
WHEN others THEN
  IF sqlcode <> -29266 then 
     raise;
  ENDIF;
END;
IF(http_resp.status_code = 200) then 
L_RESP_XML:= xmltype(response_env);

L_RESULTCODE:= l_resp_xml.extract('/s:Envelope/s:Body/GetResponse/GetResult/a:ResultHeader/b:ResultCode/text()', 'xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/ xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:b="http://schemas.datacontract.org/2004/07/"').getstringval();
L_RESULTDESCRIPTION:= l_resp_xml.extract('/s:Envelope/s:Body/GetResponse/GetResult/a:ResultHeader/b:ResultDescription/text()', 'xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/ xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:b="http://schemas.datacontract.org/2004/07/.CRM"').getstringval()

IF (l_resultcode = '0' AND l_resultdescription = 'Successful') then 
    siebel.idc_ir_xml_processing(response_env, err_code , err_mesg);
    IF (err_code <> '00') then 
        error_code := err_code;error_desc := err_mesg;raise error_out;
    ELSE
      error_code := '00T';
      error_desc := l_resultdescription;raise error_out
    ENDIF;
 ENDIF;

utl_http.end_response(http_resp);
error_code := '00';
error_desc := 'SUCCESS';
EXCEPTION
   WHEN error_out THEN 
      error_code := error_code;error_desc := error_desc; ---SQLERRM||' Unhandled Exception';
    WHEN others THEN 
      error_code := '91';error_desc := sqlerrm || ' Unhandled Exception';
    dbms_output.put_line('Error desc:' || error_desc );
END;

当我们进行测试时,我们多次调用上述过程,它会调用 HTTP 请求并获得响应。但是当我们触发大部分时间时,我们都会遇到错误

Error desc:ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-29270: too many open HTTP requests

让我们知道上述过程中的问题是什么以及如何处理所有请求连接应该关闭。以及如何确保我们不会再次出现该问题

【问题讨论】:

ORA-29270: too many open HTTP requests的可能重复 【参考方案1】:

始终使用 utl_http.end_response 关闭打开的连接以防出现任何异常。

http_req := utl_http.begin_request(t_url,'POST', utl_http.http_version_1_1);
utl_http.set_header(http_req, 'Content-Type', t_content_type);
utl_http.set_header(http_req, 'Content-Length', length(soap_request));
utl_http.set_header(http_req, 'SOAPAction', 'http://tempuri.org/IService/GetActive');
utl_http.write_text(http_req, soap_request);
http_resp := utl_http.get_response(http_req);
Utl_Http.read_text(http_resp, response_env,32767);
dbms_lob.createtemporary(x_clob, false );
bms_lob.OPEN( x_clob, dbms_lob.lob_readwrite );
BEGIN
  loop utl_http.read_text(http_resp, l_buffer); 
    dbms_lob.writeappend(x_clob, length(l_buffer) , l_buffer); 
  end LOOP;
EXCEPTION 
WHEN others THEN
  IF sqlcode <> -29266 then 
     raise;
  ENDIF;
END;
IF(http_resp.status_code = 200) then 
L_RESP_XML:= xmltype(response_env);

L_RESULTCODE:= l_resp_xml.extract('/s:Envelope/s:Body/GetResponse/GetResult/a:ResultHeader/b:ResultCode/text()', 'xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/ xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:b="http://schemas.datacontract.org/2004/07/"').getstringval();
L_RESULTDESCRIPTION:= l_resp_xml.extract('/s:Envelope/s:Body/GetResponse/GetResult/a:ResultHeader/b:ResultDescription/text()', 'xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/ xmlns:a="http://schemas.datacontract.org/2004/07/" xmlns:b="http://schemas.datacontract.org/2004/07/.CRM"').getstringval()

IF (l_resultcode = '0' AND l_resultdescription = 'Successful') then 
    siebel.idc_ir_xml_processing(response_env, err_code , err_mesg);
    IF (err_code <> '00') then 
        error_code := err_code;error_desc := err_mesg;raise error_out;
    ELSE
      error_code := '00T';
      error_desc := l_resultdescription;raise error_out
    ENDIF;
 ENDIF;

utl_http.end_response(http_resp);
error_code := '00';
error_desc := 'SUCCESS';
EXCEPTION
   WHEN error_out THEN
      utl_http.end_response(http_resp); 
      error_code := error_code;error_desc := error_desc; ---SQLERRM||' Unhandled Exception';
    WHEN others THEN 
      utl_http.end_response(http_resp); 
      error_code := '91';error_desc := sqlerrm || ' Unhandled Exception';
     dbms_output.put_line('Error desc:' || error_desc );

END;

【讨论】:

以上是关于ORA-29273: HTTP 请求失败,ORA-29270: 打开的 HTTP 请求太多的主要内容,如果未能解决你的问题,请参考以下文章

Oracle 10g UTL_HTTP begin_request 返回 ORA-29273: HTTP 请求失败

ORA-29270:从pl / sql过程调用webservice时,有太多打开的HTTP请求

仅当URL变为LONG时,ORA-29263才会抛出错误

PL/SQL/Oracle DB:过程:ORA-29013:SSL MAC 验证失败(数据库 19c)

使用 Oracle APEX 对自签名、未经认证的网站进行 REST 调用

请求 utl_http 包时 Oracle 错误“ORA-28759:打开文件失败”