l_url => url of web service
l_env => request xml in clob file
v_clob => response xml in clob file
create or replace
PROCEDURE getResponseXMLfromURL (l_url IN VARCHAR2, l_env IN clob, v_clob out clob)
IS
http_req UTL_HTTP.req;
http_resp UTL_HTTP.resp;
l_text VARCHAR2(32767);
begin
http_req := UTL_HTTP.begin_request (l_url, 'POST', 'HTTP/1.1');
UTL_HTTP.set_body_charset (http_req, 'UTF-8');
UTL_HTTP.set_header (http_req, 'Content-Type', 'text/xml');
UTL_HTTP.set_header (http_req, 'Content-Length', LENGTH (l_env));
UTL_HTTP.set_header (http_req, 'SOAPAction', 'runReport');
UTL_HTTP.write_text (http_req, l_env);
http_resp := UTL_HTTP.get_response (http_req);
-- utl_http.read_text(http_resp, v_clob);
-- utl_http.end_response(http_resp);
DBMS_LOB.createtemporary(v_clob, FALSE);
-- Copy the response into the CLOB.
BEGIN
LOOP
UTL_HTTP.read_text(http_resp, l_text, 32767);
DBMS_LOB.writeappend (v_clob, LENGTH(l_text), l_text);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(http_resp);
END;
end;