Question on utl_http.

Hi,
I am very new to UTL_HTTP package..
I am trying to call one of my webservice using this package..here is the code for this
CREATE OR REPLACE PACKAGE BODY prepaid_service AS
FUNCTION get_prepaid(transactionNumber IN VARCHAR2, transactionType IN VARCHAR2) RETURN VARCHAR2 IS
req demo_soap.request;
resp demo_soap.response;
URL VARCHAR2(200);
ACTION VARCHAR2(200);
BEGIN
req := demo_soap.new_request('n:header',
'xmlns:n="urn:examples:prepaid"');
demo_soap.add_parameter(req, 'transactionNumber', 'xsd:string', transactionNumber);
demo_soap.add_parameter(req, 'type', 'xsd:string', transactionType);
URL := 'http://10.72.149.179:8080/soap/servlet/rpcrouter';
ACTION := NULL;
resp := demo_soap.invoke(req,URL,ACTION);
RETURN demo_soap.get_return_value(resp, 'return','xmlns:ns1="urn:examples:prepaid"');
END;
BEGIN
* Since the Web service resides outside of the firewall, we need to set
* the proxy in the current session before invoking the service.
utl_http.set_proxy('www-proxy', NULL);
utl_http.set_persistent_conn_support(TRUE);
END;
The exception handling illustrates the use of "pragma-ed" exceptions
like Utl_Http.Http_Client_Error. In a realistic example, the program
would use these when it coded explicit recovery actions.
Request_Failed is raised for all exceptions after calling
Utl_Http.Set_Detailed_Excp_Support ( enable=>false )
And it is NEVER raised after calling with enable=>true
CREATE OR REPLACE PACKAGE BODY demo_soap AS
FUNCTION new_request(method IN VARCHAR2,
namespace IN VARCHAR2)
RETURN request AS
req request;
BEGIN
req.method := method;
req.namespace := namespace;
RETURN req;
END;
PROCEDURE add_parameter(req IN OUT NOCOPY request,
name IN VARCHAR2,
reqtype IN VARCHAR2,
value IN VARCHAR2) AS
BEGIN
req.reqbody := req.reqbody ||'<'||name||' xsi:type="'||reqtype||'">'||value||'</'||name||'>';
END;
PROCEDURE generate_envelope(req IN OUT NOCOPY request,
               env IN OUT NOCOPY VARCHAR2) AS
BEGIN
env := '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"     xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><soap:Body><'||req.method||' '||req.namespace||'>'||req.reqbody||'</'||req.method||'></soap:Body></soap:Envelope>';
END;
PROCEDURE show_envelope(env IN VARCHAR2) AS
i pls_integer;
len pls_integer;
BEGIN
i := 1; len := length(env);
WHILE (i <= len) LOOP
dbms_output.put_line(substr(env, i, 60));
i := i + 60;
END LOOP;
END;
PROCEDURE check_fault(resp IN OUT NOCOPY response) AS
fault_node xmltype;
fault_code VARCHAR2(256);
fault_string VARCHAR2(32767);
BEGIN
fault_node := resp.doc.extract('/soap:Fault','xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/');
IF (fault_node IS NOT NULL) THEN
fault_code := fault_node.extract('/soap:Fault/faultcode/child::text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
fault_string := fault_node.extract('/soap:Fault/faultstring/child::text()', 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
raise_application_error(-20000, fault_code || ' - ' || fault_string);
END IF;
END;
FUNCTION invoke(req IN OUT NOCOPY request,
url IN VARCHAR2,
action IN VARCHAR2) RETURN response AS
env VARCHAR2(32767);
http_req utl_http.req;
http_resp utl_http.resp;
resp response;
BEGIN
generate_envelope(req, env);
     show_envelope('url='||url);
     show_envelope('action='||action);
     show_envelope(env);
-- show_envelope(env);
http_req := utl_http.begin_request(url,'POST','HTTP/1.0');
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(env));
utl_http.set_header(http_req, 'SOAPAction', action);
utl_http.write_text(http_req, env);
http_resp := utl_http.get_response(http_req);
utl_http.read_text(http_resp, env);
utl_http.end_response(http_resp);
resp.doc := xmltype.createxml(env);
resp.doc := resp.doc.extract('/soap:Envelope/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
show_envelope(resp.doc.getstringval());
check_fault(resp);
RETURN resp;
     --RETURN NULL;
END;
FUNCTION invoke11 RETURN response AS
req demo_soap.request;
env VARCHAR2(32767);
http_req utl_http.req;
http_resp utl_http.resp;
resp response;
     URL VARCHAR2(200);
     ACTION VARCHAR2(200);
BEGIN
dbms_output.put_line('IN invoke11');
req := demo_soap.new_request('n:header',
'xmlns:n="urn:examples:prepaid"');
demo_soap.add_parameter(req, 'transactionNumber', 'xsd:string','1234');
demo_soap.add_parameter(req, 'type', 'xsd:string', 'transactionType');
     URL := 'http://10.72.149.179:8080/soap/servlet/rpcrouter';
     ACTION := NULL;
     generate_envelope(req, env);
          dbms_output.put_line('gen env');
     show_envelope('url='||url);
     show_envelope('action='||action);
     show_envelope(env);
-- show_envelope(env);
http_req := utl_http.begin_request(url,'POST','HTTP/1.0');
     dbms_output.put_line('after B req');
utl_http.set_header(http_req, 'Content-Type', 'text/xml');
utl_http.set_header(http_req, 'Content-Length', length(env));
utl_http.set_header(http_req, 'SOAPAction', action);
     dbms_output.put_line('start write');
utl_http.write_text(http_req, env);
     dbms_output.put_line('end write');
http_resp := utl_http.get_response(http_req);
     dbms_output.put_line('end resp');
utl_http.read_text(http_resp, env);
utl_http.end_response(http_resp);
resp.doc := xmltype.createxml(env);
resp.doc := resp.doc.extract('/soap:Envelope/soap:Body/child::node()',
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
show_envelope(resp.doc.getstringval());
check_fault(resp);
RETURN resp;
     --RETURN NULL;
END;
FUNCTION get_return_value(resp IN OUT NOCOPY response,
name IN VARCHAR2,
namespace IN VARCHAR2) RETURN VARCHAR2 AS
BEGIN
RETURN resp.doc.extract('//'||name||'/child::text()',namespace).getstringval();
END;
END;
when i called first procedure(get_prepaid), it is not working it is giving error as "ORA-12545: Connect failed because target host or object does not exist
ORA-06512: at "SYS.UTL_HTTP", line 1020
ORA-06512: at "RMS_BATCH.PREPAID_SERVICE", line 36
ORA-06512: at line 10"
But when i try run demo_soap.invoke11(), it is giving me proper output.. Couldn't find out why this error is coming..I am trying to run invoke11() from TOAD.
Please help me in resolving this problem..
Thanks in advance
Satya

/apps
bkrdlr@tsrdclvmappq# ls -ld /apps/bkrdlr/interface_files/
drwxrwsr-x 3 oraqabdc mqm 4096 Mar 29 16:51 /apps/bkrdlr/interface_files/
/apps
bkrdlr@tsrdclvmappq# ls -ld /apps/bkrdlr
drwxrwxr-x 12 bkrdlr mqm 4096 Mar 30 09:34 /apps/bkrdlr
/apps
bkrdlr@tsrdclvmappq# ls -ld /apps
drwxr-xr-x 7 root root 4096 Jul 27  2010 /apps
/apps
bkrdlr@tsrdclvmappq# sqlplus cms/cms
SQL*Plus: Release 11.1.0.7.0 - Production on Wed Mar 30 17:20:15 2011
Copyright (c) 1982, 2008, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE    11.1.0.7.0      Production
TNS for IBM/AIX RISC System/6000: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
SQL>Thank you.

Similar Messages

  • Question: How to call a BPEL process from a PL/SQL procedure

    Hi All,
    Greetings to all BPEL people. I have a question on how can we call a BPEL process from a PLSQL procedure. It might be a stupid question but i wanted to know whether this fetaure is available in BPEL as our scenario requires us to explore if this functionality is available in BPEL.
    Please let me know and also if possible please send me the links for the tutorials if it is available.
    Thanks In Advance,
    Dibya

    Yes u can do it. there are two ways.
    1) First one is using utl_http package of PL/SQL
    In this case u can create SOAP request message & send it as Http request to your deployed BPEL process.
    This package provides some methods like
    set_header,write_text,get_response,read_text etc..
    Following is part of code which may be helpful to you.
    create or replace package body test_book_order_sub_pkg
    is
    FUNCTION test_book_order_sub(p_subscription_guid IN RAW,
    p_event IN OUT WF_EVENT_T
                                            Return VARCHAR2 IS
    soap_request varchar2(30000);
    soap_respond varchar2(30000);
    http_req utl_http.req;
    http_resp utl_http.resp;
    launch_url varchar2(240) ;
         begin
         DBMS_OUTPUT.Put_Line('Subscription : Order has been booked');
         soap_request:='<?xml version="1.0" encoding="UTF-8"?>
         <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header/>
    <soap:Body xmlns:ns1="http://xmlns.oracle.com/BES_BookOrder">
    <ns1:BES_BookOrderProcessRequest>
    <ns1:input>725</ns1:input>
    </ns1:BES_BookOrderProcessRequest>
    </soap:Body>
    </soap:Envelope>';
    http_req:= utl_http.begin_request
    ('http://172.28.5.191:8888/orabpel/default/BES_BookOrder/1.0',
    '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', 'initiate');
         utl_http.write_text(http_req, soap_request) ;
    http_resp:= utl_http.get_response(http_req) ;
    utl_http.read_text(http_resp, soap_respond) ;
    utl_http.end_response(http_resp) ;
    DBMS_OUTPUT.Put_Line(soap_respond);
    return('SUCCESS');
    end test_book_order_sub;
    end test_book_order_sub_pkg;
    2) Second way is make your BPEL process listening to some database Queue(use AQ Adapter). & then put some message in tht queue from ur Pl/SQL code . This will also initiate BPEL instance. Check out AQAdapter tutorials.
    /mishit

  • A question about error with jasperserver for pdf and Apex

    I have created a pdf report on jasperserver and I can call it from apex via a url and it displays fine. The url is this format {http://server:port/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/reports/Apex/deptemp&output=pdf&deptNo=#DEPTNO#&j_username=un&j_password=pw}
    However, I am trying to follow a stored procedure executed from Apex so it would not expose the username/pwd in the url like above.
    If I am reading the apache error log correctly it is erroring in this piece of the code below where it executes {Dbms_Lob.writeAppend}
    loop
    begin
    -- read the next chunk of binary data
    Utl_Http.read_raw(vResponse, vData);
    -- append it to our blob for the pdf file
    Dbms_Lob.writeAppend
    ( lob_loc => vBlobRef
    , amount => Utl_Raw.length(vData)
    , buffer => vData
    exception when utl_http.end_of_body then
    exit; -- exit loop
    end;
    end loop;
    Utl_Http.end_response(vResponse);}
    The error log says this; HTTP-500 ORA-14453: attempt to use a LOB of a temporary table, whose data has alreadybeen purged\n
    What is this error telling me and how can I correct it?
    The stored procedure I am following is below but replaced the vReportURL with my url like above that works.
    Thank you,
    Mark
    {CREATE OR REPLACE procedure runJasperReport(i_deptno   in varchar2)
    is
    vReportURL       varchar2(255);
    vBlobRef         blob;
    vRequest         Utl_Http.req;
    vResponse        Utl_Http.resp;
    vData            raw(32767);
    begin
    -- build URL to call the report
    vReportURL := 'http://host:port/jasperserver/flow.html?_flowId=viewReportFlow'||
         '&reportUnit=/reports/Apex/deptemp'||
         '&output=pdf'||
         '&j_username=un&j_password=pw'||
         '&deptNo='||i_deptno;
    -- get the blob reference
    insert into demo_pdf (pdf_report)
    values( empty_blob() )
    returning pdf_report into vBlobRef;
    -- Get the pdf file from JasperServer by simulating a report call from the browser
    vRequest := Utl_Http.begin_request(vReportUrl);
    Utl_Http.set_header(vRequest, 'User-Agent', 'Mozilla/4.0');
    vResponse := Utl_Http.get_response(vRequest);
    loop
    begin
    -- read the next chunk of binary data
    Utl_Http.read_raw(vResponse, vData);
    -- append it to our blob for the pdf file
    Dbms_Lob.writeAppend
    ( lob_loc => vBlobRef
    , amount  => Utl_Raw.length(vData)
    , buffer  => vData
    exception when utl_http.end_of_body then
    exit; -- exit loop
    end;
    end loop;
    Utl_Http.end_response(vResponse);
    owa_util.mime_header('application/pdf',false);
    htp.p('Content-length: ' || dbms_lob.getlength(vBlobRef));
    owa_util.http_header_close;
    wpg_docload.download_file(vBlobRef);
    end runJasperReport;
    /}

    I am new to working with working with jasperserver to apex interfacing, and also using utl_http with binary data.
    But I guess typing my question down helped me figure out a way to make it work for me.
    I combined info from http://www.oracle-base.com/articles/misc/RetrievingHTMLandBinariesIntoTablesOverHTTP.php
    and from http://sqlcur.blogspot.com/2009_02_01_archive.html
    to come up with this procedure.
    {create or replace PROCEDURE download_file (p_url  IN  VARCHAR2) AS
      l_http_request   UTL_HTTP.req;
      l_http_response  UTL_HTTP.resp;
      l_blob           BLOB;
      l_raw            RAW(32767);
    BEGIN
      -- Initialize the BLOB.
      DBMS_LOB.createtemporary(l_blob, FALSE);
      -- Make a HTTP request, like a browser had called it, and get the response
      l_http_request  := UTL_HTTP.begin_request(p_url);
      Utl_Http.set_header(l_http_request, 'User-Agent', 'Mozilla/4.0');
      l_http_response := UTL_HTTP.get_response(l_http_request);
      -- Copy the response into the BLOB.
      BEGIN
        LOOP
          UTL_HTTP.read_raw(l_http_response, l_raw, 32767);
          DBMS_LOB.writeappend (l_blob, UTL_RAW.length(l_raw), l_raw);
        END LOOP;
      EXCEPTION
        WHEN UTL_HTTP.end_of_body THEN
          UTL_HTTP.end_response(l_http_response);
      END;
    -- make it display in apex
    owa_util.mime_header('application/pdf',false);
    htp.p('Content-length: ' || dbms_lob.getlength(l_blob));
    owa_util.http_header_close;
    wpg_docload.download_file(l_blob);
      -- Release the resources associated with the temporary LOB.
    DBMS_LOB.freetemporary(l_blob);
    EXCEPTION
      WHEN OTHERS THEN
        UTL_HTTP.end_response(l_http_response);
        DBMS_LOB.freetemporary(l_blob);
        RAISE;
    END download_file; }
    Don;t know what I did wrong, but I could not create an 'on-demand' process to call my procedure. I did not understand what it means when it says 'To create an on-demand page process, at least one application level process must be created with the type 'ON-DEMAND'.
    so I had to use a blank page with a call to my procedure in the onload - before header process and that seems to work ok.
    Thank you,
    Mark

  • Few questions about apex + epg and cookie blocked by IE6

    Hi,
    I would like to ask a few questions about apex and epg.
    I have already installed and configured apex 3.2 on oracle 10g (on my localhost - computer name 'chen_rong', ip address -192.168.88.175 ), and enable anonymous access xdb http server.
    now,
    1. I can access 'http://chen_rong' , 'http://localhost' , 'http://192.168.88.175' without input username / password for realm 'XDB' in IE6;
    2. I can access 'http://localhost/apex/apex_admin' , 'http://192.168.88.175/apex/apex_admin' , and I can be redirected into apex administation page after input admin/<my apex admin password> for realm 'APEX' in IE6;
    3. I can access 'http://chen_rong/apex/apex_admin' in IE6, but after input admin/password , I can not be redirected into administation page, because the cookie was blocked by IE6.
    then, the first question is :
    Q1: What is the difference among 'http://chen_rong' , 'http://localhost' , 'http://192.168.88.175' ? I have already include site 'chen_rong' into my trusted stes! why the cookie was blocked by IE6. I have already tried firefox and google browser, both of them were ok for 'chen_rong', no cookie blocked from site 'chen_rong'!
    and,
    1. I have tried to use the script in attachment to test http authentication and also want to catch the cookie by utl_http .
    2. please review the script for me.
    3. I did:
    SQL> exec show_url('http://localhost/apex/apex_admin/','ADMIN','Passw0rd');
    HTTP response status code: 401
    HTTP response reason phrase: Unauthorized
    Please supplied the required Basic authentication username/password for realm XDB for the Web page.
    Web page http://localhost/apex/apex_admin/ is protected.
    MS-Author-Via: DAV
    DAV: 1,2,<http://www.oracle.com/xdb/webdav/props>
    Server: Oracle XML DB/Oracle Database
    WWW-Authenticate: Basic realm="XDB"
    Date: Tue, 04 Aug 2009 02:25:15 GMT
    Content-Type: text/html; charset=GBK
    Content-Length: 147
    ======================================
    PL/SQL procedure successfully completed
    4. I also did :
    SQL> exec show_url('http://localhost/apex/apex_admin/','ANONYMOUS','ANONYMOUS');
    HTTP response status code: 500
    HTTP response reason phrase: Internal Server Error
    Check if the Web site is up.
    PL/SQL procedure successfully completed
    SQL> exec show_url('http://localhost/apex/apex_admin/','SYSTEM','apexsite');
    HTTP response status code: 401
    HTTP response reason phrase: Unauthorized
    Please supplied the required Basic authentication username/password for realm APEX for the Web page.
    Web page http://localhost/apex/apex_admin/ is protected.
    Content-Type: text/html
    Content-Length: 147
    WWW-Authenticate: Basic realm="APEX"
    ======================================
    PL/SQL procedure successfully completed
    my second questions is :
    Q2: After I entered into realm 'XDB', I still need went into realm'APEX'. how could I change the script show_url to accomplish these two tasks and successfully get the cookie from site.
    the show_url script is as following:
    CREATE OR REPLACE PROCEDURE show_url
    (url IN VARCHAR2,
    username IN VARCHAR2 DEFAULT NULL,
    password IN VARCHAR2 DEFAULT NULL)
    AS
    req UTL_HTTP.REQ;
    resp UTL_HTTP.RESP;
    name VARCHAR2(256);
    value VARCHAR2(1024);
    data VARCHAR2(255);
    my_scheme VARCHAR2(256);
    my_realm VARCHAR2(256);
    my_proxy BOOLEAN;
    cookies UTL_HTTP.COOKIE_TABLE;
    secure VARCHAR2(1);
    BEGIN
    -- When going through a firewall, pass requests through this host.
    -- Specify sites inside the firewall that don't need the proxy host.
    -- UTL_HTTP.SET_PROXY('proxy.example.com', 'corp.example.com');
    -- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
    -- rather than just returning the text of the error page.
    UTL_HTTP.SET_RESPONSE_ERROR_CHECK(FALSE);
    -- Begin retrieving this Web page.
    req := UTL_HTTP.BEGIN_REQUEST(url);
    -- Identify yourself.
    -- Some sites serve special pages for particular browsers.
    UTL_HTTP.SET_HEADER(req, 'User-Agent', 'Mozilla/4.0');
    -- Specify user ID and password for pages that require them.
    IF (username IS NOT NULL) THEN
    UTL_HTTP.SET_AUTHENTICATION(req, username, password, 'Basic', false);
    END IF;
    -- Start receiving the HTML text.
    resp := UTL_HTTP.GET_RESPONSE(req);
    -- Show status codes and reason phrase of response.
    DBMS_OUTPUT.PUT_LINE('HTTP response status code: ' || resp.status_code);
    DBMS_OUTPUT.PUT_LINE
    ('HTTP response reason phrase: ' || resp.reason_phrase);
    -- Look for client-side error and report it.
    IF (resp.status_code >= 400) AND (resp.status_code <= 499) THEN
    -- Detect whether page is password protected
    -- and you didn't supply the right authorization.
    IF (resp.status_code = UTL_HTTP.HTTP_UNAUTHORIZED) THEN
    UTL_HTTP.GET_AUTHENTICATION(resp, my_scheme, my_realm, my_proxy);
    IF (my_proxy) THEN
    DBMS_OUTPUT.PUT_LINE('Web proxy server is protected.');
    DBMS_OUTPUT.PUT('Please supply the required ' || my_scheme ||
    ' authentication username/password for realm ' || my_realm ||
    ' for the proxy server.');
    ELSE
    DBMS_OUTPUT.PUT_LINE('Please supplied the required ' || my_scheme ||
    ' authentication username/password for realm ' || my_realm ||
    ' for the Web page.');
    DBMS_OUTPUT.PUT_LINE('Web page ' || url || ' is protected.');
    END IF;
    ELSE
    DBMS_OUTPUT.PUT_LINE('Check the URL.');
    END IF;
    -- UTL_HTTP.END_RESPONSE(resp);
    -- RETURN;
    -- Look for server-side error and report it.
    ELSIF (resp.status_code >= 500) AND (resp.status_code <= 599) THEN
    DBMS_OUTPUT.PUT_LINE('Check if the Web site is up.');
    UTL_HTTP.END_RESPONSE(resp);
    RETURN;
    END IF;
    -- HTTP header lines contain information about cookies, character sets,
    -- and other data that client and server can use to customize each
    -- session.
    FOR i IN 1..UTL_HTTP.GET_HEADER_COUNT(resp) LOOP
    UTL_HTTP.GET_HEADER(resp, i, name, value);
    DBMS_OUTPUT.PUT_LINE(name || ': ' || value);
    END LOOP;
    -- Read lines until none are left and an exception is raised.
    --LOOP
    -- UTL_HTTP.READ_LINE(resp, value);
    -- DBMS_OUTPUT.PUT_LINE(value);
    --END LOOP;
    UTL_HTTP.GET_COOKIES(cookies);
    dbms_output.put_line('======================================');
    FOR i in 1..cookies.count LOOP
    IF (cookies(i).secure) THEN
    secure := 'Y';
    ELSE
    secure := 'N';
    END IF;
    -- INSERT INTO my_cookies
    -- VALUES (my_session_id, cookies(i).name, cookies(i).value,
    -- cookies(i).domain,
    -- cookies(i).expire, cookies(i).path, secure, cookies(i).version);
    dbms_output.put_line('site:'||url);
    dbms_output.put_line('cookies:');
    dbms_output.put_line('name:'||cookies(i).name);
    dbms_output.put_line('value:'||cookies(i).value);
    dbms_output.put_line('domain:'||cookies(i).domain);
    dbms_output.put_line('expire:'||cookies(i).expire);
    dbms_output.put_line('path:'||cookies(i).path);
    dbms_output.put_line('secure:'||secure);
    dbms_output.put_line('version:'||cookies(i).version);
    END LOOP;
    UTL_HTTP.END_RESPONSE(resp);
    EXCEPTION
    WHEN UTL_HTTP.END_OF_BODY THEN
    UTL_HTTP.END_RESPONSE(resp);
    END;
    /

    I use oracle database enterprise edtion 10.2.0.3. I have already figured out the epg on 10.2.0.3 to support apex 3.2.
    And as I described above, the apex site works fine for ip address , and localhost. but the cookie will be blocked by IE6, if I want to access the site by 'http://computername:port/apex/apex_admin'. This problem does not occured in firefox and google browser. Could someone give me answer?

  • Error invoking SSL web service using pl sql UTL_HTTP

    Web Services Gurus,
    I am invoking a secure web service based on the following WSDL file from a pl/sql program using UTL_HTTP package.
    The web service is secure and prompts for authentication.
    The web services certificate is imported in Oracle Wallet on Database Server.
    I am listing the WSDL file, the pl/sql code and error message as follows -
    1. The WSDL file -
    <definitions
    name="Webservice"
    targetNamespace="http://webservice.airclic.com/"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://webservice.airclic.com/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    >
    <types>
    <xs:schema targetNamespace="http://webservice.airclic.com/" version="1.0" xmlns:tns="http://webservice.airclic.com/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Exception" type="tns:Exception"/>
    <xs:element name="sendAuthenticationResponse" type="tns:sendAuthenticationResponse"/>
    <xs:element name="sendAuthenticationResponseResponse" type="tns:sendAuthenticationResponseResponse"/>
    <xs:complexType name="AuthenticationResponse">
    <xs:complexContent>
    <xs:extension base="tns:Response">
    <xs:sequence>
    <xs:element name="success" type="xs:boolean"/>
    <xs:element name="username" type="xs:string"/>
    <xs:element minOccurs="0" name="password" type="xs:string"/>
    <xs:element minOccurs="0" name="firstName" type="xs:string"/>
    <xs:element minOccurs="0" name="lastName" type="xs:string"/>
    <xs:element minOccurs="0" name="email" type="xs:string"/>
    <xs:element minOccurs="0" name="active" type="xs:boolean"/>
    <xs:element minOccurs="0" name="timeZone" type="xs:string"/>
    <xs:element minOccurs="0" name="group" type="xs:string"/>
    <xs:element minOccurs="0" name="role" type="xs:string"/>
    <xs:element minOccurs="0" name="errorCode" type="xs:string"/>
    <xs:element minOccurs="0" name="errorMessage" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="DispatchEvent"></xs:complexType>
    <xs:complexType name="sendAuthenticationResponse">
    <xs:sequence>
    <xs:element minOccurs="0" name="authenticationResponse" type="tns:AuthenticationResponse"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="sendAuthenticationResponseResponse">
    <xs:sequence/>
    </xs:complexType>
    <xs:simpleType name="status"></xs:simpleType>
    <xs:simpleType name="source"></xs:simpleType>
    <xs:simpleType name="eventType"></xs:simpleType>
    </xs:schema>
    </types>
    <message name="Webservice_sendAuthenticationResponse">
    <part name="sendAuthenticationResponse" element="tns:sendAuthenticationResponse"/>
    </message>
    <message name="Webservice_sendAuthenticationResponseResponse">
    <part name="sendAuthenticationResponseResponse" element="tns:sendAuthenticationResponseResponse"/>
    </message>
    <portType name="Webservice">
    <operation name="sendAuthenticationResponse" parameterOrder="sendAuthenticationResponse">
    <input message="tns:Webservice_sendAuthenticationResponse"/>
    <output message="tns:Webservice_sendAuthenticationResponseResponse"/>
    <fault name="Exception" message="tns:Exception"/>
    </operation>
    </portType>
    <binding name="WebserviceBinding" type="tns:Webservice">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="sendAuthenticationResponse">
    <soap:operation soapAction=""/>
    <input>
    <soap:body use="literal"/>
    </input>
    <output>
    <soap:body use="literal"/>
    </output>
    <fault name="Exception">
    <soap:fault name="Exception" use="literal"/>
    </fault>
    </operation>
    </binding>
    <service name="Webservice">
    <port name="WebservicePort" binding="tns:WebserviceBinding">
    <soap:address location="https://host.airclic.com:443/webservice/product/fieldservice/v1/Webservice"/>
    </port>
    </service>
    </definitions>
    2. The pl/sql code that calls the web service operation sendAuthenticationResponse
    procedure send_auth_response
    as
    soap_request varchar2(30000);
    soap_respond varchar2(30000);
    http_req utl_http.req;
    http_resp utl_http.resp;
    resp XMLType;
    i integer;
    begin
    -- initiate wallet for AirClic certificate
    dbms_output.put_line ('1');
    utl_http.set_wallet('file:/etc/oracle/wallet','<wallet password>');
    -- create soap request
    dbms_output.put_line ('2');
    soap_request:= '<?xml version = "1.0" encoding = "UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <SOAP-ENV:Body>
    <ns1:sendAuthenticationResponse xmlns="https://host.airclic.com:443/webservice/product/fieldservice/v1/Webservice" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <success xsi:type="xsd:boolean">true</success>
    <username xsi:type="xsd:string">changlanih</username>
    <password xsi:type="xsd:string">abcd1234</password>
    <firstName xsi:type="xsd:string">hero</firstName>
    <lastName xsi:type="xsd:string">changlani</lastName>
    <email xsi:type="xsd:string">[email protected]</email>
    <active xsi:type="xsd:boolean">true</active>
    <timeZone xsi:type="xsd:string">eastern</timeZone>
    <group xsi:type="xsd:string">Northeast</group>
    <role xsi:type="xsd:string">Service Manager</role>
    <errorCode xsi:type="xsd:string"></errorCode>
    <errorMessage xsi:type="xsd:string"></errorMessage>
    </ns1:sendAuthenticationResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>';
    -- request that exceptions are raised for error Status Codes
    dbms_output.put_line ('3');
    utl_http.set_response_error_check (true);
    -- allow testing for exceptions like UTL_HTTP.http_server_error
    dbms_output.put_line ('4');
    utl_http.set_detailed_excp_support (true);
    --utl_http.set_transfer_timeout (ln_time_out);
    dbms_output.put_line ('5');
    utl_http.set_body_charset ('UTF-8');
    -- begin request
    dbms_output.put_line ('5.5');
    http_req:= utl_http.begin_request
    ('https://host.airclic.com:443/webservice/product/fieldservice/v1/Webservice/sendAuthenticationResponse', ------ is the url correct here ?
    'POST',
    'HTTP/1.1'
    dbms_output.put_line ('6');
    utl_http.set_authentication(http_req, '<username for webservice>', '<password for webservice user>');
    dbms_output.put_line ('7');
    utl_http.set_persistent_conn_support (http_req, false);
    dbms_output.put_line ('8');
    utl_http.set_header(http_req, 'Content-Type', 'text/xml'); -- since we are dealing with plain text in XML documents
    dbms_output.put_line ('9');
    utl_http.set_header(http_req, 'Content-Length', length(soap_request));
    dbms_output.put_line ('10');
    utl_http.set_header(http_req, 'SOAPAction', ''); -- required to specify this is a SOAP communication
    dbms_output.put_line ('11');
    utl_http.write_text(http_req, soap_request);
    dbms_output.put_line ('12');
    http_resp := utl_http.get_response(http_req);
    -- debug messages
    DBMS_OUTPUT.PUT_LINE('-------utl_http.get_response---------------------');
    DBMS_OUTPUT.PUT_LINE('http_resp.status_code is :'||http_resp.status_code );
    DBMS_OUTPUT.PUT_LINE('http_resp.reason_phrase is :'||http_resp.reason_phrase);
    DBMS_OUTPUT.PUT_LINE('http_resp.http_version is :'||http_resp.http_version);
    DBMS_OUTPUT.PUT_LINE('http_resp.private_hndl is :'||http_resp.private_hndl);
    DBMS_OUTPUT.PUT_LINE('-------utl_http.get_response----------------------');
    utl_http.read_text(http_resp, soap_respond);
    dbms_output.put_line ('13');
    utl_http.end_response(http_resp);
    dbms_output.put_line ('14');
    resp := XMLType.createXML(soap_respond);
    dbms_output.put_line ('15');
    resp := resp.extract('/soap:Envelop/soap:Body/child::node()',
    'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
    i:=0;
    dbms_output.put_line ('16');
    loop
    dbms_output.put_line(substr(soap_respond, 1 + i * 255, 250));
    i := i + 1;
    if (i * 250) > length(soap_respond) then
    exit;
    end if;
    end loop;
    exception
    when utl_http.request_failed then
    dbms_output.put_line('request failed: ' || utl_http.get_detailed_sqlerrm);
    when utl_http.http_server_error then
    dbms_output.put_line('server error: ' || utl_http.get_detailed_sqlerrm);
    when utl_http.http_client_error then
    dbms_output.put_line('client error: ' || utl_http.get_detailed_sqlerrm);
    when others then
    dbms_output.put_line(sqlerrm);
    end send_auth_response;
    3. Output when I run the send_auth_response procedure
    Connecting to the database cpdev.
    1
    2
    3
    4
    5
    5.5
    ORA-12560: TNS:protocol adapter error
    Process exited.
    Disconnecting from the database cpdev.
    Comments -
    The web service operation only has input message. The input message consists of a complex type as seen in WSDL.
    Questions -
    1. This is my first attempt in invoking a web service from pl/sql program. Is the code in SOAP body correct as mapped to the complex type in WSDL ?
    2. As seen from the dbms_out - the last message before ORA-12560 is 5.5, that means the call is erroring at following code line -
    http_req:= utl_http.begin_request ------ what am I doing wrong here ?
    3. The web service is SSL as seen from WSDLand needs a username/password for access - which is being performed by following code line -
    utl_http.set_authentication(http_req, '<username for webservice>', '<password for webservice user>'); ------- is that correct ?
    4. I am not using any proxy server - should I be using it ? When is it necessary to use proxy ?
    Appreciate any help.
    Thanx.

    Oracle is hosted by HOST A - this is where the pl/sql program resides.
    The Web Service being accessed by pl/sql program is hosted by HOST B and there are 4 firewalls in between.
    Oracle was not even able to establish connection to web services host.
    Escalated the issue with networking folks and they resolved the connectivity problem.
    Hope that helps.

  • Using utl_http tp post a mod_plsql package which has a parameter

    Hi,
    I'm new to using utl_http, xml and mod_plsql.
    I need to test calling a mod_plsql package which receives posted data and returns a response using utl_http.
    The following works fine:
    SET SERVEROUTPUT ON;
    CREATE OR REPLACE PROCEDURE http_test
    IS
    BEGIN
    HTP.p (
    '<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Goodbye!</body></note>
    END http_test;
    CREATE OR REPLACE FUNCTION HTTP_POST
    RETURN VARCHAR2
    IS
    req UTL_HTTP.req;
    resp UTL_HTTP.resp;
    v_txt VARCHAR2 (1024);
    posted_data VARCHAR2 (1000)
    := '<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Hello!</body></note>';
    BEGIN
    wallet_is_set_here;
    req :=
    UTL_HTTP.begin_request (
    'https://url details removed for security/http_test',
    'POST',
    'HTTP/1.1');
    UTL_HTTP.write_text (req, posted_data);
    resp := UTL_HTTP.get_response (req);
    UTL_HTTP.read_text (resp, v_txt);
    UTL_HTTP.end_response (resp);
    RETURN v_txt;
    END;
    SELECT http_post FROM DUAL;
    i.e. it returns the following as expected:
    <?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Goodbye!</body></note>
    However, I want to pass a parameter to the http_test procedure so I can ultimately save the posted data to a table so I can process the contents later.
    If I change the code to:
    CREATE OR REPLACE PROCEDURE http_test (xmlX IN VARCHAR2)
    IS
    BEGIN
    HTP.p (
    '<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Goodbye!</body></note>
    END http_test;
    CREATE OR REPLACE FUNCTION HTTP_POST
    RETURN VARCHAR2
    IS
    req UTL_HTTP.req;
    resp UTL_HTTP.resp;
    v_txt VARCHAR2 (1024);
    posted_data VARCHAR2 (1000)
    := '<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Hello!</body></note>';
    BEGIN
    wallet_is_set_here;
    req :=
    UTL_HTTP.begin_request (
    'https://url details removed for security/http_test',
    'POST',
    'HTTP/1.1');
    UTL_HTTP.set_header (req, 'Content-Type', 'text/xml; charset=utf-8');
    UTL_HTTP.set_header (req, 'Content-Length', LENGTH (posted_data));
    UTL_HTTP.write_text (req, posted_data);
    resp := UTL_HTTP.get_response (req);
    UTL_HTTP.read_text (resp, v_txt);
    UTL_HTTP.end_response (resp);
    RETURN v_txt;
    END;
    SELECT http_post FROM DUAL;
    I just get a load of html returned (some of which is below to show the kind of thing):
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x
    html1/DTD/xhtml1-strict.dtd">
    <html dir=LTR xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="pragma" content="no-cache" />
    </head>
    <body>
    Please could someone advise me what I am doing wrong or if it is not possible to post in this way using utl_http. I'm hoping it is just a question of finding the correct settings but can't find an example that matches what we need to do.
    If I post in a browser using an html form to the procedure when it has a parameter, the response is displayed correctly in the browser and it can be saved to a database(code not included in the above). However, our requirement is to do this in the background as we will be receiving a post from an external customer to which we have to respond based on the contents of the posted data.
    Many thanks for any help.

    Hi,
    Do you mind updating your message and using enclose the code part between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Please read <a href="https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002">How do I ask a question on the forums?</a> for more details.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Exception when working with UTL_HTTP.read_text

    Hi,
    I have written a block of code to read XML from a URL and then I write it to a file, using UTL_HTTP package.
    The code has been working fine for two months and all of a sudden, I get the following error while reading from one of the URLs:
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line
    1327
    ORA-06502: PL/SQL: numeric or value error
    The piece of code is pasted below for your reference.
    http_req := utl_http.begin_request('my_url','GET','HTTP/1.1');
    utl_http.set_body_charset(http_req, 'UTF-8');
    utl_http.set_header(http_req, 'Content-Type', 'text/xml');
    http_resp:= utl_http.get_response(http_req);
    LOOP
         UTL_HTTP.read_text(http_resp, l_text, 32767);
         UTL_FILE.PUT_LINE(file_handle, l_text);
    END LOOP;However, when I reduce the number of characters to be read in UTL_HTTP.read_text to 30000, it works. FYI, it isn't working with 32000 as well, while it worked perfect with 32767 all this while. This exception came up today.
    I understand this has something to do with the data being read, however, my question is:
    1. If I specify that 32767 characters are to be read, why should there be a buffer problem? (I am executing the same procedure for 10 other URLs and they are working fine. Its just one URL which has given a problem today)
    2. What is a good solution to implement? If i reduce the number to 30000 to solve the problem today, and it gives the same problem the next time, reducing the number further doesn't look like a permanent solution.
    Appreciate your help on this. Please let me know if I need to furnish any more details on this.

    Roger,
    I have another question here. I declare the text into which I am reading my response chunk as:
    l_text          VARCHAR2(32767 char);rather than plainly declaring it as:
    l_text          VARCHAR2(32767);the second method defaults it to 32767 bytes, but isn't the first way taking it as 32767 character values?
    Even now I get the same exception. Any clue here?

  • Internal Oracle Error in SYS.UTL_HTTP.READ_TEXT - ORA-6512 @ line 1336

    I have a PLSQL program that performs an HTTP POST to fetch data from an external website. The website is returning the contents of a file in the HTTP response. This program has been working for years and just started giving us trouble recently at a particular client. The issue cannot be reproduced locally, only on a specific client machine when trying to download a particular set of XML files through this HTTP interface.
    The stack trace is:
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line 1336
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SYS.UTL_HTTP", line 1336The code in question is:
    PROCEDURE SEND_REQUEST
        p_REQUEST      IN CLOB,
        p_RESPONSE     OUT CLOB,
        p_HEADERNAMES  OUT STRING_COLLECTION,
        p_HEADERVALUES OUT STRING_COLLECTION,
        p_ERRORMESSAGE OUT VARCHAR2
    ) IS
        v_HTTP_REQ    UTL_HTTP.REQ;
        v_HTTP_RESP   UTL_HTTP.RESP;
        v_REQUEST_LEN NUMBER;
        v_POS         NUMBER;
        v_COUNT       NUMBER;
        v_TEXT        VARCHAR2(8192);
        v_LEN         NUMBER;
    BEGIN
        -- raise Request_Failed error if an HTTP error occurs
        UTL_HTTP.SET_RESPONSE_ERROR_CHECK(TRUE);
        UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(FALSE);
        -- extend timeout to 10 minutes
        UTL_HTTP.SET_TRANSFER_TIMEOUT(60 * 10);
        v_HTTP_REQ := UTL_HTTP.BEGIN_REQUEST(G_URL, 'POST');
        -- disable cookies for this request
        UTL_HTTP.SET_COOKIE_SUPPORT(v_HTTP_REQ, FALSE);
        -- authentication
        IF g_USERNAME IS NOT NULL THEN
            UTL_HTTP.SET_AUTHENTICATION(v_HTTP_REQ, g_USERNAME, g_PASSWORD);
        END IF;
        -- upload request body
        v_REQUEST_LEN := DBMS_LOB.GETLENGTH(p_REQUEST);
        UTL_HTTP.SET_HEADER(v_HTTP_REQ, 'Content-Type', 'application/x-www-form-urlencoded');
        UTL_HTTP.SET_HEADER(v_HTTP_REQ, 'Content-Length', v_REQUEST_LEN);
        -- write the CLOB request data
        v_POS := 1;
        WHILE v_POS <= v_REQUEST_LEN LOOP
            v_LEN := 8192;
            DBMS_LOB.READ(p_REQUEST, v_LEN, v_POS, v_TEXT);
            UTL_HTTP.WRITE_TEXT(v_HTTP_REQ, v_TEXT);
            v_POS := v_POS + v_LEN;
        END LOOP;
        -- get the response
        v_HTTP_RESP := UTL_HTTP.GET_RESPONSE(v_HTTP_REQ);
        -- read it into CLOB
        DBMS_LOB.CREATETEMPORARY(p_RESPONSE, TRUE);
        DBMS_LOB.OPEN(p_RESPONSE, DBMS_LOB.LOB_READWRITE);
        LOOP
            BEGIN           
                UTL_HTTP.READ_TEXT(v_HTTP_RESP, v_TEXT, 8192);       
            EXCEPTION
                WHEN UTL_HTTP.END_OF_BODY THEN
                    ERRS.LOG_AND_CONTINUE('Send_Request: Exeception occurred reading text from the http response.',
                                          p_LOG_LEVEL => LOGS.C_LEVEL_INFO_MORE_DETAIL);
                    v_TEXT := '';
            END;
            EXIT WHEN NVL(LENGTH(v_TEXT), 0) = 0;   
            DBMS_LOB.WRITEAPPEND(p_RESPONSE, LENGTH(v_TEXT), v_TEXT);
        END LOOP;
        DBMS_LOB.CLOSE(p_RESPONSE);
        -- gather response headers
        p_HEADERNAMES := STRING_COLLECTION();
        p_HEADERVALUES := STRING_COLLECTION();
        v_COUNT := UTL_HTTP.GET_HEADER_COUNT(v_HTTP_RESP);
        v_POS := 1;
        WHILE v_POS <= v_COUNT LOOP
            p_HEADERNAMES.EXTEND();
            p_HEADERVALUES.EXTEND();   
            UTL_HTTP.GET_HEADER(v_HTTP_RESP, v_POS, p_HEADERNAMES(p_HEADERNAMES.LAST), p_HEADERVALUES(p_HEADERVALUES.LAST));
            v_POS := v_POS + 1;   
        END LOOP;
        UTL_HTTP.END_RESPONSE(v_HTTP_RESP);
        -- success!
        p_ERRORMESSAGE := NULL;
    EXCEPTION
        WHEN UTL_HTTP.REQUEST_FAILED THEN
            ERRS.LOG_AND_CONTINUE('Send_Request: Exeception Request Failed caught.', p_LOG_LEVEL => LOGS.C_LEVEL_INFO_MORE_DETAIL);   
        WHEN OTHERS THEN
            ERRS.LOG_AND_CONTINUE('Send_Request: Exeception Others caught.', p_LOG_LEVEL => LOGS.C_LEVEL_INFO_MORE_DETAIL);   
    END SEND_REQUEST;It fails specifically at the section that is reading text from the response:
    UTL_HTTP.READ_TEXT(v_HTTP_RESP, v_TEXT, 8192);
    ...Any thoughts?
    I have used a packet sniffer, Wireshark, to monitor the HTTP traffic between the website and database during the issue. There is nothing malformed with the Response content. No special chars that I can find. Etc.
    The machine in question that is failing is running 10gR2.
    I have done some searching and I found this forum post:
    utl_http.read_text and multi-byte support
    and this Oracle bug:
    https://support.oracle.com/CSP/main/article?cmd=show&type=BUG&id=4015165&productFamily=Oracle
    Not really much help.
    Any help would be appreciated.
    Thanks,
    GatorPaul
    Edited by: 939368 on Jun 7, 2012 2:27 PM

    In this case, and most cases, the NLS_LENGTH_SEMANTICS is set to 'BYTE'. Realize that this is an Oracle application that we deploy into an external customer environment and we do not always have the ability to control NLS Settings.
    So, based on your explanation, I would expect that an approach like this would fix it:
    v_TEXT VARCHAR2(32766);
    UTL_HTTP.READ_TEXT(v_HTTP_RESP, v_TEXT, 8192);
    Here we are saying, get the next 8192 characters, but put that into a buffer that allows up to 32K bytes. This should allow for the enough room for up to 4 bytes per character. Am I understanding you correctly?
    But here is my question:
    I put a fix in place today, where I increased both the v_TEXT byte size and the GET_TEXT 'len' parameter to 32766 and it fixed the issue. By doing that, I am telling it: Give me the next 32766 characters and put it into a VARCHAR2(32766). Given your explanation, I would expect this to overflow the v_TEXT variable as well, or at least have the potential to do so.
    We were processing 5 different XML responses. They were all failing originally. After the change, they all passed. Their sizes were 47K, 21K, 14K, 48K, and 21K. If the XML file was small, < 32K then maybe is slipped under the radar given the new buffer size of 32766. But what about the 2 files that were over 32K. Very curious on your thoughts. I did not have a loop counter in there to see how many times it was looping to parse the 48K file. With a new buffer size of 32K I would expect it to loop 2x. But, I know in this case, the file was streamed over the network using 14 smaller TCP packets, none of which were more than 9000 bytes. Maybe the PLSQL looped 14 times as well.
    When the process was failing for all 5 files, I do know at that time it was always failing on the first loop (first 8192 characters).
    Anyway, Thanks for the advice. I will let you guys know if I uncover anymore info.
    G8torPaul
    Edited by: G8torPaul on Jun 12, 2012 2:04 PM
    Edited by: G8torPaul on Jun 12, 2012 2:04 PM
    Edited by: G8torPaul on Jun 12, 2012 2:05 PM

  • UTL_HTTP IN ORACLE 10G

    Dear All,
    I have tried with the below block
    DECLARE
    req   utl_http.req;
    resp  utl_http.resp;
    value VARCHAR2(1024);
    BEGIN
      req := utl_http.begin_request('http://www.psoug.org');
      utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
      resp := utl_http.get_response(req);
      LOOP
        utl_http.read_line(resp, value, TRUE);
        dbms_output.put_line(value);
      END LOOP;
      utl_http.end_response(resp);
    EXCEPTION
      WHEN others then
      dbms_output.put_line(sqlerrm);
    END;
    /but i am getting the below error.
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line 1029
    ORA-12535: TNS:operation timed outcan anyone suggets me how to resolve this problem??
    Cheers,
    San

    qwe16235 wrote:
    What is the situation, we could use UTL_HTTP?Well, any time that you have some service sitting on a web server that you need to access from the database. That could be a web service. It could be a web page that you want to scrape. It could be a file that is made available on a web server somewhere.
    We find UTL_HTTP process 10000 rows/hour. It it reasonable?I'm not sure what you're asking. I'm not sure whether you are asking a question about an existing database or whether you're asking about a design for a new system.
    Are you stating/ envisioning that you see that the database server is making one UTL_HTTP call every hour, the server responds with 10,000 rows of data, and you process those rows? Or are you stating/ envisioning that you see the database server making 10,000 UTL_HTTP calls every hour and getting one row of data each time? How many sessions do you envision making those calls? How long does the web server take to process a request and return the data?
    If you're talking about a potential design, 10,000 calls per hour is less than 3 calls per second. Assuming the web server is reasonably quick and that you don't need to do much processing of the results, that's probably only 5-10 database sessions going full bore which isn't terribly difficult to do technically. Architecturally, it would tend to be a bit odd to have the database server making that many HTTP calls-- that is normally something that middle tier application servers would do. Since we don't know what problem you're trying to solve, though, it's impossible to know whether you have a reasonable need to make those calls from the database server.
    Justin

  • UTL_HTTP, different error codes: APEX SQL Commands vs. Oracle SQL Developer

    Hi, omniscient all!
    I have a code sample where I try to request some URL from an inactive server:
    declare
      l_text varchar2(32000);
    begin
      l_text := utl_http.request('http://inactive.url:7777');
    exception
      when others then
        declare
          l_errcode number := utl_http.get_detailed_sqlcode;
        begin
          dbms_output.put_line(l_errcode);
          dbms_output.put_line(sqlerrm(l_errcode));
        end;
    end;
    /When I run it in Oracle SQL Developer it shows:
    anonymous block completed
    -12541
    ORA-12541: TNS:no listenerWhen I run it in the APEX 4.0 SQL Commands window it shows:
    -29263
    ORA-29263: HTTP protocol error
    Statement processed.The question is: why?
    In real world, I need to make a HTTP POST request (no problem) and catch some exceptions. But instead of the usual ORA-12541 error APEX throws an ORA-29261 one.

    Any thoughts?

  • Utl_http authentication

    Not an Apex question, but hoping some of the Oracle Web Gurus may know the answer, or can point me in the right direction.
    I need to retrieve XML into my 10g database, from a website that requires authentication. Username and Password is done via HTML form on the front page, once authenticated a session (SID) is produced. All interaction from then on is via session.cgi in the URL.
    Is there any way I can use utl_http to interact with the website , to POST the username and password (via the login form) , and retrieve the session ID? So I can make further URL calls to retrieve the XML.
    Thanks in advance.

    The docs describe the entire API. Please read through with a little more diligence. You can have the login form send a 'POST' request as belowreq := UTL_HTTP.BEGIN_REQUEST (url=>'www.abc.com', method=>'POST');
    UTL_HTTP.SET_HEADER (r      =>  req,
                         name   =>  'Content-Type',  
                         value  =>  'application/x-www-form-urlencoded');
    UTL_HTTP.SET_HEADER (r      =>   req,
                         name   =>   'Content-Length',
                         value  =>'  <length of data posted in bytes>');
    UTL_HTTP.WRITE_TEXT (r      =>   req,
                         data   =>   'username=value1&passwd=value2...');
    resp := UTL_HTTP.GET_RESPONSE
                         (r     =>   req);
    .... process response Varad

  • Utl_http.SET_HEADER

    Hi to all ....
    I have a package that use wpg_docload.download_file to show a file stored in the database
    Now a customer ask to me if i can add some hader information
    Somethig like in java is
    resp.addHeader ('meta-doc_id','12345');
    How can I do this in my package ???
    can be something like
    utl_http.SET_HEADER(HTTP_REQ, ('meta-docid','12345');

    Am not a Java programmer and can only guess what the Java code does.
    As for using wpg_docload.download_file - the sample code I posted above is exactly how one goes about creating a HTTP header to stream data using wpg_docload.download_file.
    As for the special tag you needs to create. That will be done as I've shown in the example. How the actual tag looks like - that is hard to say from the code snippet you've posted that creates the tag using Java. The question is how does that actual tag looks like in the HTTP header - and not what the "equivalent" command in PL/SQL is for that Java command that creates the tag.
    In other words, the requirement specification should be "+create this tag in the header and this is how it looks like+".
    Not "+here's the Java statement, now duplicate it in PL/SQL+". This is not a sensible or logical requirement by any stretch of the imagination.
    In your sh0es, I will insist on a proper technical specification that details how that HTTP response needs to look like. What is expected in the HTTP header? What is expected in the HTTP body/payload? Don't show me Java code as the requirement and say "duplicate this". That is not how software is designed and engineered.

  • Utl_http ssl request error

    Hi
    Oracle 8.1.7, solaris 8
    I have a problem using utl_http.request with SSL
    I export certificate from Internet explorer, set up wallet manager and import
    certificates with wallet manager.
    But when I access secure sites using sql*plus I got an error
    select utl_http.request('https://securesites',null, 'file:/oas/wallets',
    'wallet_passwd') from dual;
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "SYS.UTL_HTTP", line 174
    ORA-06512: at line 1
    I have seen the same problem in metalink but no clear solution!
    Viesturs

    How does your question relate to the Oracle Forms product? I recommend you post your question in the PL/SQL forum. If you have a general Forms question, by all means, ask it here! ;-)
    Craig...

  • Clarification regarding UTL_HTTP.REQUEST_PIECES

    Hi all,
    I am having a java program which will keep on listening in particular port.
    And i am having a stored procedure which uses the UTL_HTTP.REQUEST_PIECES package to post the message.
    RES_PIECES utl_http.html_pieces;
    VURL VARCHAR2(2000) := 'http://1.1.1.1:8080/FileName.htm?msg='abcd';
    RES_PIECES := UTL_HTTP.REQUEST_PIECES(VURL);
    But here, when the java application picks the message,it is showing that the message is posted in GET method and not in POST method.
    I want the messages to be posted in POST METHOD.
    Is there any other option which i need to set for this.
    Please clarify.
    Regards
    Nathan

    Actually Michael is exactly correct.Naturally ;)
    Seriously Eric,
    If I had to guess, I think Nathan is trying to accomplish a machine-to-machine poor man's Web Service, making use of the UTL_HTTP package. Using a <FORM method="POST"> is entirely dependent upon human interactivity...
    I did one of these with PayPal, which worked quite well.
    If I am right about my guess, the next logical question could be, who cares whether it is GET or POST, as long as it works? Since it is machine-to-machine, does it really matter? Of course it does, if moderate to large amounts of data need to be passed, as query strings have their limitations... In the example given by Nathan, it should matter, though.
    Michael O'Neill
    Publisher of the PigiWiki
    clever-idea.com

  • UTL_HTTP Fails After Large Number of Requests

    Hello,
    The following code issues an HTTP request, obtains the response, and closes the response. After a significantly large number of iterations, the code causes the session to terminate with an "END OF FILE ON COMMUNICATIONS CHANNEL" error (Oracle Version 10.2.0.3). I have the following two questions that I hope someone can address:
    1) Could you please let me know if you have experienced this issue and have found a solution?
    2) If you have not experienced this issue, are you able to successfully run the following code below in your test environment?
    DECLARE
    http_req utl_http.req;
    http_resp utl_http.resp;
    i NUMBER;
    BEGIN
    i := 0;
    WHILE i < 200000
    LOOP
    i := i + 1;
    http_req := utl_http.begin_request('http://<<YOUR_LOCAL_TEST_WEB_SERVER>>', 'POST', utl_http.HTTP_VERSION_1_1);
    http_resp := utl_http.get_response(http_req);
    utl_http.end_response(http_resp);
    END LOOP;
    dbms_output.put_line('No Errors Occurred. Test Completed Successfully.');
    END;
    Thanks in advance for your help.

    I believe the end_request call is accomplished implicitly through the end_response function based on the documentation that I have reviewed. However, to be sure, I had attempted your suggestion as it also had occurred to me. Unfortunately, after attempting the end_request, I received an error since the request was already implicitly closed. Therefore, the assumption is that the end_request call is not applicable in this context. Thanks for the suggestion though. If you have any other suggestions, please let me know.

Maybe you are looking for

  • Working with iPhoto pix in iMovie '11

    Two questions on working with iPhoto pictures in iMovie '11: Is there a way to control the sort order of pictures in an iPhoto event in iMovie '11? Or, looking at it from a different perspective, how does iMovie '11 sort photos when I'm browsing an i

  • Caching XSLT results?

    Hi, I am a newbie to XML/XSLT, and we have just written our first XSL stylesheet. I am using the WebLogic JSP Tag Library to do the transformation from XML to HTML and all seems to work well. My question is this: Does WebLogic cache the HTML somewher

  • Reverse proxing on non-standard ports

    Hi, I want to create a new Reverse proxy mapping between an application and a GlassFish instance running on non standard port (not 80 / 443). Creating a mapping for HTTP works fine, but I can't find a way to map both the http and the https ports to t

  • How to upgrade Aperture with insufficient disk space

    Hi, I am trying to upgrade to the latest version of Aperture (from 3.4.3 to 3.4.4). I downloaded the update from the App Store but now whenever I try to launch Aperture it says that there is insufficient space on the library volume to perform the upg

  • Ipad not streaming iphoto

    my Ipad2 has stopped photo streaming. The iphone and apple tv are still doing it and everything has the same settings....