oracle 在 utl_http.req 中发送长度为 32000 的 CLOB 数据抛出 ORA:06052 POST 方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21643294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:13:30  来源:igfitidea点击:

Sending CLOB data of length 32000 in utl_http.req throws ORA:06052 POST method

sqloraclefunction

提问by ferenit

I am trying to send an XML as a URL parameter from PL/SQL. But when I try to send it the error "ORA:06052" occurs. Below is the PL/SQL code

我试图从 PL/SQL 发送一个 XML 作为 URL 参数。但是当我尝试发送它时,会出现错误“ORA:06052”。下面是PL/SQL代码

      CREATE OR REPLACE FUNCTION EMASDB.ESIGN(TY IN VARCHAR2,DATA1 IN CLOB,DATA2 IN CLOB) RETURN clob
IS
XML CLOB;
v_data_post CLOB;
resp utl_http.resp;
req  utl_http.req;
v_txt CLOB;
BEGIN
IF TY='REGISTER' THEN
XML:='<register><uniqueid>'||DATA2||'</uniqueid><DATA1>'||DATA1||'</DATA1><userEnable>true</userEnable><originalContent>'||DATA2||'</originalContent></register>';
ELSIF TY='AUTHENTICATE' THEN
XML :='<AuthenticateDet><uniqueId>'||DATA2||'</uniqueId><DATA1>'||DATA1||'</DATA1><originalContent>'||DATA2||'</originalContent><referenceNo></referenceNo></AuthenticateDet>';
ELSE
XML :='<verifyDet><dataType>pkcs7</dataType><DATA1>'||DATA1||'</DATA1><originalContent>'||DATA2||'</originalContent><responseFormat>plain</responseFormat></verifyDet>';
DBMS_OUTPUT.PUT_LINE('A');
END IF;
req  := UTL_HTTP.begin_request ('url','POST','HTTP/1.1');
utl_http.set_header(req, 'Content-Type', 'application/x-www-form-urlencoded');
utl_http.set_header(req, 'Content-Length', length(XML));
v_data_post :='xml='||XML;
/*utl_http.write_text(req, v_data_post);
resp := UTL_HTTP.get_response(req);
utl_http.read_text(resp,v_txt);
utl_http.end_response(resp);
RETURN v_txt;*/
RETURN 'done';
END;
/

回答by Brian McGinity

When you need write (and read) more than 32k in utl_http, it done a bit differently.

当您需要在 utl_http 中写入(和读取)超过 32k 的数据时,它的做法有点不同。

For example:

例如:

l_data := 'fill with some sample piece of text';
http_req := utl_http.begin_request(url => 'http://example.com', method => 'POST');
utl_http.set_header (http_req, 'Content-Length', length(l_data));
utl_http.set_header (http_req, 'Content-Type', 'text/xml;charset=UTF-8');
utl_http.set_header (http_req, 'Transfer-Encoding', 'chunked');

loop
  l_chunkData := null;
  l_chunkData := substr(l_data, l_chunkStart, l_chunkLength);
  utl_http.write_text(http_req, l_chunkData);
  if (length(l_chunkData) < l_chunkLength) then exit; end if;
  l_chunkStart := l_chunkStart + l_chunkLength;
end loop;

See: http://www.kurzhals.info/2012/03/using-chunked-transfer-with-plsql-utl_http-write_text.html

参见:http: //www.kurzhals.info/2012/03/using-chunked-transfer-with-plsql-utl_http-write_text.html

And for a clob example see: http://blog.optiosys.com/?p=246

对于 clob 示例,请参见:http://blog.optiosys.com/?p=246