Home » Developer & Programmer » JDeveloper, Java & XML » Problem with XML (Oracle 11g)
Problem with XML [message #547576] Wed, 14 March 2012 15:55 Go to next message
Spada
Messages: 14
Registered: March 2012
Junior Member

Hey guys,

Actually Im doing a WS call. My problem is that UTL_HTTP.READ_TEXT has a limit of 32k and I am trying to read a bigger XML.

So I was wondering if theres a method to that can help me with this.

  FUNCTION BE_P_INVOCAR_SERVICIO (
    soap_request IN CLOB,
    action IN VARCHAR2)
  RETURN VARCHAR2 AS
    soap_respond CLOB;                --SOAP XML COMPLETO DE LA RESPUESTA
    http_req utl_http.req;            --HTTP DEL REQUEST
    http_resp utl_http.resp;          --HTTP DEL RESPONSE
    xml_respuesta XMLType;            --XML CON EL QUE SE RECIBE LA RESPUESTA COMPLETA Y SE EXTRAE CASA SUBXML
    Pv_error VARCHAR2(3000);          --VARIABLE PARA MANEJAR EL ERROR
    xml_string VARCHAR2(32000);       --VARIABLE VARCHAR PARA LA SALIDA XML
    url_wsdl VARCHAR2(200);           --VARIABLE PARA LA URL
    LV_MENSAJEERROR VARCHAR2(200);
  BEGIN
    -- TOMA LA URL DE LA TABLA PARAMETRIZADA
    SELECT valor 
    INTO url_wsdl
    FROM MC_ALCANCE_PARAMETROS 
    WHERE parametro = 'url';
  
    -- SETEO DEL HEADER
    http_req:= UTL_HTTP.BEGIN_REQUEST(url_wsdl,'POST','HTTP/1.1');
    UTL_HTTP.SET_HEADER(http_req, 'Content-Type', 'text/xml');
    UTL_HTTP.SET_HEADER(http_req, 'Content-Length', length(soap_request));
    UTL_HTTP.SET_HEADER(http_req, 'SOAPAction', action);    -- SET DEL METODO
    UTL_HTTP.SET_TRANSFER_TIMEOUT(3000);                    -- SET DEL TIMEOUT
    UTL_HTTP.WRITE_TEXT(http_req, soap_request);            -- SET DEL REQUEST
    
    BEGIN
      http_resp:= UTL_HTTP.GET_RESPONSE(http_req);          -- CONSUMO DEL SERVICIO
    EXCEPTION
      WHEN OTHERS THEN
        Pv_error   := 'ERROR OBTENIENDO RESPONSE : VERIFIQUE..' || SQLERRM;
        INSERT INTO mc_websvr_errores(fecha_adicion, error)
        VALUES (SYSDATE, Pv_error);
    END;
    
    UTL_HTTP.READ_TEXT(http_resp, soap_respond);            -- ASIGNACION DEL RESPOND    
    
    UTL_HTTP.END_RESPONSE(http_resp);                       -- CIERRE DE RESPUESTA
         
    xml_respuesta:= sys.xmltype.CREATEXML(soap_respond);        --CREA EL XML
    COMMIT;  
    IF(xml_respuesta IS NOT NULL) THEN
      xml_string := xml_respuesta.GETSTRINGVAL();           --PASA EL XML A VARCHAR
    ELSE
      RETURN NULL;
    END IF;
    RETURN xml_string;

  EXCEPTION
    WHEN UTL_HTTP.REQUEST_FAILED THEN
      Pv_error := SUBSTR('Request_Failed 1: ' || SUBSTR(Utl_Http.Get_Detailed_Sqlerrm, 1, 282), 1, 300);
      RETURN NULL;
    WHEN UTL_HTTP.Http_Server_Error THEN
      Pv_error := SUBSTR('Http_Server_Error 1: ' ||  SUBSTR(Utl_Http.Get_Detailed_Sqlerrm, 1, 282), 1, 300);
      RETURN NULL;
    WHEN UTL_HTTP.Http_Client_Error THEN
      Pv_error := SUBSTR('Http_Client_Error: 1' ||  SUBSTR(Utl_Http.Get_Detailed_Sqlerrm, 1, 282), 1, 300);
    WHEN OTHERS THEN
      Pv_error   := 'ERROR EN BE_P_INVOCAR_SERVICIO: VERIFIQUE..' || SQLERRM;
      INSERT INTO mc_websvr_errores(fecha_adicion, error) VALUES (SYSDATE, Pv_error);
      RETURN NULL;
  END BE_P_INVOCAR_SERVICIO;

Re: Problem with XML [message #566833 is a reply to message #547576] Thu, 20 September 2012 02:30 Go to previous messageGo to next message
tigsav
Messages: 38
Registered: April 2012
Member
hi ,
Actually Read text should be in a loop.

BEGIN
LOOP
utl_http.read_text(v_response, v_chunk, 4000);
dbms_lob.writeappend(v_buffer, length(v_chunk), v_chunk);
END LOOP;
EXCEPTION

WHEN utl_http.end_of_body THEN
DBMS_OUTPUT.PUT_LINE('utl_http.end_of_body');

WHEN OTHERS THEN
/*Your appln specufic exception handling */
END;
Re: Problem with XML [message #566836 is a reply to message #566833] Thu, 20 September 2012 02:41 Go to previous message
Michel Cadot
Messages: 58529
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel
Previous Topic: Improper parsing of xml schema
Next Topic: Generating XMLfrom XSD at runtime
Goto Forum:
  


Current Time: Thu Jul 24 10:27:36 CDT 2014

Total time taken to generate the page: 0.11591 seconds