如何从 Oracle DB 11.2 调用负载超过 32000 个字符的 SOAP WS?

问题描述 投票:0回答:2

各位同事,大家好。我需要从 Oracle DB 调用 SOAP Web 服务,其中有效负载由 base64 编码的文件组成。问题是我的有效负载大小有限制 - 32 000 个字符(varchar 类型)。例如,这里这里。所以这意味着我无法调用有效负载相当大的网络服务。有没有人举例说明有效负载增加了 varchar2 类型的限制。比你。

oracle soap plsql
2个回答
0
投票

要突破 32k 字符限制,您可以尝试将

CLOB
utl_http
一起使用。这是执行此操作的程序:

PROCEDURE write_clob_to_http_request(pc_clob IN OUT NOCOPY CLOB)
IS
    ln_offset      NUMBER := 1;
    ln_i           NUMBER := 1;
    ln_amount      NUMBER := 32767;
    ln_clob_length NUMBER := dbms_lob.getlength(pc_clob);
    lv_buffer      VARCHAR2(32767);

    luh_http_request utl_http.req;
BEGIN

    luh_http_request := utl_http.begin_request('http://SoapServiceLocation' , 'POST', 'HTTP/1.1');
    utl_http.set_header(luh_http_request, 'Content-Type', lv_http_content_type);
    utl_http.set_header(luh_http_request, 'Content-Length', LENGTH(pc_content));
    utl_http.set_header(luh_http_request, 'SOAPAction', 'http://SoapServiceLocation');

    IF dbms_lob.isopen(pc_clob) != 1 THEN
        dbms_lob.open(pc_clob, 0);
    END IF;

    WHILE ( ln_offset < ln_clob_length )
    LOOP
        dbms_lob.read(pc_clob, ln_amount, ln_offset, lv_buffer);
        UTL_HTTP.write_text(luh_http_request, lv_buffer);
        ln_offset := ln_offset + ln_amount;
        ln_i := ln_i + 1;
    END LOOP; 

    IF dbms_lob.isopen(pc_clob) = 1 THEN
        dbms_lob.close(pc_clob);
    END IF;

    luh_http_response := utl_http.get_response(luh_http_request);
    utl_http.read_text(luh_http_response, pc_content);
    utl_http.end_response(luh_http_response);
END write_clob_to_http_request;

您可以通过连接

CLOB
变量轻松创建
VARCHAR2

pc_content CLOB := TO_CLOB('a string') || TO_CLOB('another string)...; 

0
投票

lv_buffer:= null ; 以避免 ora-06502

© www.soinside.com 2019 - 2024. All rights reserved.