1 Reply Latest reply: Dec 11, 2012 11:16 PM by Billy~Verreynne RSS

    utl_http read text strange issue

    user650888
      This is not the entire code sample but I tried to give a subset of what I am doing

      SO I am using utl_http to request and response to get the data, and below code snippet is in a procedure,

      I am calling the procedure twice from my main procedure, First time the read_text gives me accurate result

      But from my main procedure when I call the below procedure again, read_text is not giving me anything, just the empty xml tags

      am I missing something ? I am calling the below proc twice by passing chunks of data because size of var is exceeding 32 k
      l_http_request UTL_HTTP.req;
      l_http_response UTL_HTTP.resp;
      var VARCHAR2(32767);
      v_envl VARCHAR2(32767);
      
      Loop 
      
      
      
      Begin
      
      
      
      l_http_request := UTL_HTTP.begin_request('someipaddress', 'POST','HTTP/1.1');
      
      
      
      UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
      
      
      
      UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(var));
      
      
      
      UTL_HTTP.set_header(l_http_request, 'SOAPAction', 'http://xys.com');
      
      
      
      UTL_HTTP.write_text(l_http_request, var);
      
      
      
      -- to test
      
      --raise Utl_Http.Http_Server_Error;
      
      
      
      l_http_response := UTL_HTTP.get_response(l_http_request);
      
      
      
      exit;
      
      
      
      exception
      
      
      
      when Utl_Http.Http_Server_Error
      
      
      
      then
      
      
      
      begin
      
      
      
      null;
      
      end;
      
      
      
      end;
      
      
      
      END LOOP;
      
      
      UTL_HTTP.read_text(l_http_response, v_envl);
      
      -- PROBLEM HERE, V_ENVL VALUE HAS NO DATA IN IT, JUST TAGS when calling second time
      
      utl_http.End_response(l_http_response);
        • 1. Re: utl_http read text strange issue
          Billy~Verreynne
          Use a loop to read the HTTP response (32KB/chunk/line at a time), and then write append that response to a local CLOB. The XMLTYPE constructor can then be used to parse the CLOB into a XML DOM.

          Have a look at examples {message:id=10158148} and {message:id=10448611} for how to deal with web services via UTL_HTTP.