Utl_http.request_pieces Exception

Hi
oracle 10g
I am trying to construct a report server request url dynamically and call utl_http.request_peices to execute the url to run the report from my package. The URL string that is constructed by the package, runs sucessfully if I run the URL from the browser, but the utl_http.request_peices call bombs with utl_http.request_failed exception. When I used utl_http.get_detialed_sqlerrm to display the error this is what I found
http requestfailedORA-06553: PLS-103: Encountered the symbol "=" when expecting one of the following: etc
My url string is of type
http://<myserver>/reports/rwservlet?SRCN9659pdf_tst2&DESNAME<mypath>/<myrename>_2485_LeakId_1_20080714141944.pdf&OUTPUTIMAGEFORMAT=JPEG&p_sonris_inspection_line_id=2485&p_lr_seq_num=1
I stepped thru, added awatch and copied the url_str variable and executed the same in the browser. It ran successfully. But fails with the above mentioned error with utl_http.request_pieces call.
Any ideas?
Thanks

Had the same issue again... Problem was I was trying to run the procedure in DEBUG mode in Toad. That caused this weird error. Ran the procedure from the editor in a plsql anon block and it ran fine...
....?

Similar Messages

  • ORA-29261: bad argument using UTL_HTTP.REQUEST_PIECES

    I am running Oracle 10gR2.
    I keep getting ORA-29261: bad argument when setting the proxy either by the UTL_HTTP.SET_PROXY or UTL_HTTP.REQUEST_PIECES code. I have searched this forum and found no resolutions. I have set this proxy in the browser and it works fine. The following are excerpts of my code:
    Begin
       utl_http.set_proxy('http://myproxy/theProxyFile');
    End;The error is:
    ORA-29261: bad argument
    ORA-06512: at "SYS.UTL_HTTP", line 22
    ORA-06512: at "SYS.UTL_HTTP", line 888
    ORA-06512: at line 2
    I get the same error when trying to set the proxy via UTL_HTTP.REQUEST_PIECES.
    Thanks in advance,
    Becky
    Edited by: Becky Eisen on Aug 8, 2011 10:15 AM
    Edited by: Becky Eisen on Aug 8, 2011 10:21 AM

    After submitting this, I realized that I needed to look in the Proxy file for the actual proxy! Duh.

  • 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.end_of_body Exception Error.  Trying to Understand the Reason Why?

    I have the following PLSQL Function that returns a End_of_body Error. This started when we migrated from 10g to 11g. It is simple enough to capture so the error does not stop the Function Flow, but the error causes the OCI driver in OBIEE to error, which prevents the use of OBIEE IBOT to execute. Trying to understand why this error is occurring..not sure if we have a permissions issue on the UTL_HTTP Package or what?
    Anyone seen this problem in 11g? Suggests on resolving would be great. Thanks.
    FUNCTION AA_DEMO_PO_WSDL(IN_MESSAGE IN VARCHAR2)
    RETURN VARCHAR IS
    soap_request varchar2(30000);
    soap_respond varchar2(30000);
    http_req utl_http.req;
    http_resp utl_http.resp;
    launch_url varchar2(240) ;
    o_message varchar2(240) ;
    po_amount number := 2000 ;
    total_calls number := 0;
    cursor c_PO_exists is Cursor Logic..
    begin
    total_calls := 0;
    For po_wsdl in c_PO_exists
    LOOP
    total_calls := total_calls + 1;
    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/PurchaseOrder_Approval">
    <ns1:ProcessRequest><ns1:input>PO' || po_wsdl.order_no || '</ns1:input></ns1:ProcessRequest>
    </soap:Body>
    </soap:Envelope>';
    Begin
    http_req:= utl_http.begin_request('myURL/PurchaseOrder_Approval/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) ;
    Exception
    WHEN UTL_HTTP.end_of_body THEN
    utl_http.end_response(http_resp);
    When utl_http.too_many_requests then
    utl_http.end_response(http_resp);
    o_message := 'End_Reponse' || ' from proc.';
    when OTHERS then
    o_message := SQLERRM || ' from proc.';
    return o_message;
    end;
    END LOOP;
    Return 'Workflow Initiated-' ||to_char(total_calls);
    end AA_DEMO_PO_WSDL;

    Hi, thanks,
    it is oracle10g,
    The Exception is : ORA-29266: end-of-body reached
    ORA-06512: at "SYS.UTL_HTTP", line 1349
    then the line in my function ,
    damorgan wrote:
    But I do note that when I do this I always do a get_header_count and get_header before get_read.what get_read , u mean?
    thanks for the link ,
    appreciated

  • Utl_http.request_pieces

    Hello, I am trying to use this function to call a report from a PL/SQL-DB procedure. First time works but the second or third i get
    OWS-05101: Execution failed due to Oracle error 3113
    ORA-03113: end-of-file on communication channel
    I am using Oracle6i as CGI, and PL/SQL cartridge running on AOS 4.08 and DB 8i.
    Do I have to setup reports as a Cartridge too, for this to work?.
    Thanks.

    Had the same issue again... Problem was I was trying to run the procedure in DEBUG mode in Toad. That caused this weird error. Ran the procedure from the editor in a plsql anon block and it ran fine...
    ....?

  • URGENT: Content Services using PL/sql utl_http

    I'm using Oracle Collaboration Suite Content Services Version 10.1.2.0.0 (Oracle 10g Enterprise Edition Release 10.1.0.4.0).
    Using PL/sql, I want to be able to retrieve a html document stored in a folder in Content Services, and store the contents of that document in a table.
    I can retrieve and store the contents of the document if it stored anywhere - I just can't when the document resides in Content Services.
    Within PL/sql I am authenticating using utl_http.set_authentication, then using utl_http.request_pieces.
    I'm not getting an error message, just the "<" character stored in my table.
    Can I not use utl_http.request_pieces for retrieving a document in Content Services?
    Thanks
    Paul

    HI Michiel
    I am also trying to achieve something similar to that. I am trying to call a web service that sends an xml attachment over MTOM? Kindly, let me know if this was achievable from your end? I mean how did the issue got resolved.
    thanks
    vijay

  • Downloading of PPT using UTL_HTTP

    Hi All,
    I want one solution such a way that we have some urls stored in our database, so we are going to retrive the data that are in ppt format from this urls and store it in the ppt format in our database and my problem is the urls are password protected thats why when we use utl_http package we are getting blank ppt getting saved. So i want a solution as to how can we authenticate in the process ,while retrieving data from url.Can anybody please help me.
    Thanks
    Edited by: dil84 on Jan 19, 2009 11:45 PM

    Hello,
    Take a look at the following thread -
    Re: UTL_HTTP.REQUEST_PIECES on a page that needs log in
    Hope this helps,
    John
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Max Concurrent connections supported by UTL_HTTP

    Hi,
    Can anyone help me out to find how many concurrent connections can UTL_HTTP.REQUEST_PIECES support. Is there any parameter that governs max no.of connections? If so, pls post the parameter name.

    Assaf:  as always, thanks so much for the info!
    When you say double-sided, do you mean a memory stick which has chips on both sides; as in 8 chips on each side?
    I bought the Kingston memory one stick of 128MB PC100/PC133 which has chips on one side.  I also bought the 256MB PC100/PC133 which has chips on both sides.
    I currently have both these memory sticks in the MS 6119 and they appear to be working well.  I am running Prime95 torture test just to make sure everything is working as it should be.
    Currently I have the following memory in the MS 6119:
    Bank 0 - the original PC100 128MB stick which has 8 chips on each side.
    Bank 1 - the Kingston (KVR133Q/128R) PC100/PC133 128MB with 8 chips on one side.
    Bank 2 - the kingston (KVR 133Q/256R) PC100/PC133 256MB with 8 chips on both sides.
    The total is, of course is 512MB - and appears to be working just fine.  Windows LOVES RAM  :D

  • How to call a URL from forms ?

    Dear All,
    I would like to invoke / call a URL from forms. I know we can make a call Using Web.show_document. But this will execute in a browser.
    What i need to do is, i have to send a request to by calling an URL, that should not visible to any body.
    This is my requirement, please help if you know.
    Thanks
    Balaji

    hi,
    here is a quick example : (data from url returns as a clob. you need to write it at db. and call from forms.)
    FUNCTION Get_DataFromUrl(pUrl IN VARCHAR2,pProxy IN VARCHAR2,pData IN OUT CLOB) RETURN NUMBER IS
    vRcv UTL_HTTP.HTML_PIECES;
    vData CLOB;
    eNoDataReceived EXCEPTION;
    BEGIN
    UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(TRUE);
    -- Get data pieces from Url
    vRcv := UTL_HTTP.REQUEST_PIECES(pUrl,Proxy => pProxy);
    IF vRcv.COUNT < 1 THEN
    RAISE eNoDataReceived;
    ELSE
    -- Append varchar2 table data into clob variable
    DBMS_LOB.CreateTemporary(vData,FALSE,DBMS_LOB.CALL);
    FOR i IN 1..vRcv.COUNT LOOP
    DBMS_LOB.WriteAppend(vData,LENGTH(vRcv(i)),vRcv(i));
    END LOOP;
    -- Copy local data into return variable
    DBMS_LOB.Copy(pData,vData,DBMS_LOB.GetLength(vData));
    DBMS_LOB.FreeTemporary(vData);
    END IF;
    RETURN SUCCESS;
    EXCEPTION
    WHEN eNoDataReceived THEN
    RETURN FAILURE;
    WHEN UTL_HTTP.INIT_FAILED THEN
    RETURN FAILURE;
    WHEN UTL_HTTP.Request_Failed THEN
    RETURN FAILURE;
    WHEN OTHERS THEN
    RETURN FAILURE;
    END Get_DataFromUrl;
    hope this helps.
    Engin.

  • Oracle Configurator Version

    DB Server:
    Oracle Linux 5.5
    10.2.0.4.0 DB Version
    Application Server:
    Redhat EL 5.5
    EBS 12.0.6
    How does one figure out the version of "oracle configurator"? In a recent SR I was asked this question by Oracle support. Their method for me to find out was to run the following:
    http://<hostname>:<portnum>/configurator/oracle.apps.cz.servlet.UiServlet?test=version
    The above never worked. Next I was instructed to run the following:
    set serveroutput on;
    declare
    pieces utl_http.html_pieces;
    l_sql_code number;
    l_sql_errm varchar2(2000);
    begin
    utl_http.set_detailed_excp_support (enable => true);
    pieces := utl_http.request_pieces('http://myappsserver.mydomain.com:8000/configurator/oracle.apps.cz.servlet.UiServlet?test=version');
    for i in 1 .. pieces.count loop
    dbms_output.put_line(pieces(i));
    end loop;
    exception
    when others then
    l_sql_code := utl_http.get_detailed_sqlcode;
    l_sql_errm := utl_http.get_detailed_sqlerrm;
    dbms_output.put_line('detail err code: '|| l_sql_code);
    dbms_output.put_line('detail err message: '|| l_sql_errm);
    end;
    The above never worked either, and Oracle support seemed to just give up on wanting to know the version. I am now being asked the version again by a developer. What is correct way to get version information?
    Edited by: ovlz on Feb 15, 2011 7:11 AM

    Thanks. I did the following which I found in the installaton guide:
    http://myserver.mydomain.com:8000/OA_HTML/configurator/UiServlet?test=version
    It came back with:
    Using configuration software build: 12.0.0.27.11
    I found the information I needed in:
    Oracle Configurator Installation Guide B28680-05

  • Accessing PL/SQL table in SQL query

    Hello,
    Is it possible to use plain SQL to query PL/SQL table? In my case this table is returned by UTL_HTTP.REQUEST_PIECES function, which is defined as:
    create or replace package utl_http is
    type html_pieces is table of varchar2(2000) index by binary_integer;
    function request_pieces (url in varchar2,
    max_pieces natural default 32767)
    return html_pieces;
    pragma restrict_references (request_pieces, wnds, rnds, wnps, rnps);
    Generally, I want to access chunks of external data for comparison without using PL/SQL. Thanks ahead for ideas. Ideally, I need working example because my attempts to use TABLE & CAST failed.

    I was going to suggest you could try and create your own wrapper around utl_http and use a database type, but then I remembered this excellent thread which covers it better than I ever could - Billy, hope you don't mind passing on your good work!
    Re: Error using UTL_HTTP over HTTPS

  • Need code for call a report from stored produre in oracle9i(using rwclient)

    dear all,
    i need a stored procedure to run the report 9i(.rdf) from pl/sql.But i have code in older version(rwcgi60).So i want stored procedure for rwclient.
    The below code not working in oracle9i version.its very urgent.Thanks in advance..
    create table report
    (id number not null primary key,
    filename varchar2(100) not null,
    report_connection_id number not null,
    destype varchar2(5) not null)
    create table report_connection
    (id number not null primary key,
    user_id varchar2(100) not null,
    pass varchar2(100) not null,
    database_server varchar2(50) not null,
    report_server varchar2(50) not null)
    alter table cm.report add foreign key (report_connection_id) references cm.report_connection (id)
    insert into report_connection values (1, 'scott', 'tiger', 'orcl', 'Rep60_Dev');
    insert into report values (1, 'test.rdf', 1, 'PDF');
    commit;
    procedure pr_example (p_id report.id%type) is
    cursor cur_data is
    select r.filename,
    c.user_id,
    c.pass,
    r.destype,
    c.database_server,
    c.report_server
    from report r,
    report_connection c
    where r.report_connection_id = c.id
    and r.id = p_id;
    v_blob blob;
    v_url varchar2(2000);
    v_pieces utl_http.html_pieces;
    v_buffer raw(2000);
    v_buffer_size integer := 2000;
    begin
    for v_rec in cur_data loop
    v_url := 'yourserver.domain.com/dev60cgi/rwcgi60.exe?report=' || v_rec.filename || '&desformat=' ||
    v_rec.destype || '&userid=' || v_rec.user_id || '/' || v_rec.pass || '@' || v_rec.database_server ||
    '&server=' ||v_rec.report_server || '&destype=cache';
    if v_rec.destype = 'PDF' then
    owa_util.mime_header('application/pdf', false);
    htp.p('content-disposition: filename='||v_rec.filename);
    owa_util.http_header_close;
    --you can add a bunch of elsif logic here for different destypes and setting the correct mime type.
    end if;
    --sets transfer timeout to be one hour
    utl_http.set_transfer_timeout(3600);
    --runs the report
    v_pieces := utl_http.request_pieces(v_url,64000);
    v_blob := empty_blob();
    dbms_lob.createtemporary(v_blob,true);
    for i in 1 .. v_pieces.count loop
    v_buffer := utl_raw.cast_to_raw(v_pieces(i));
    v_buffer_size := utl_raw.length(v_buffer);
    if v_buffer_size > 0 then
    dbms_lob.writeappend(v_blob, v_buffer_size, v_buffer);
    end if;
    end loop;
    wpg_docload.download_file(v_blob);
    end loop;
    end;
    Now run this url:
    http://yourserver.domain.com/pls/dad_name/pr_example?p_id=1
    regards
    mani

    JosAH wrote:
    A couple of years ago Sun supplied their javax.comm package (mysteriously versioned as version 2)
    but they stopped it for the PC Windows.
    There's an alternative: rxtx which offers an identical API as Sun did and their own native implementation for serial and parallel port handling; I have used both and the rxtx version is clearly superior to Sun's old version: http://www.rxtx.org
    This question popped up recently.
    tschodt wrote in [http://forums.sun.com/thread.jspa?messageID=10863769#10863769:}
    [Java Communications API|http://java.sun.com/products/javacomm/]
    Implementations of the API are currently available for Solaris SPARC, Solaris x86, and Linux x86.follow the Download link to find
    Sun no longer offer's the Windows platform binaries of javax.comm, however javax.comm 2.0.3 can be used for the Windows platform, by using it in conjunction with the Win32 implementation layer provided by the RxTx project. To use that, download javax.comm for the 'generic' platform (which provides the front-end javax.comm API only, without platform specific back-end implementations bundled). Then acquire the Windows binary implementation rxtx-2.0.7pre1 from http://www.rxtx.org.

  • User Authentication for subfolder not working in Web Browser

    We are using Oracle Application Server 10.1.2.3 and Database Server 10.2.0.5 for our application.
    One of the functionalities of the Application is to send emails with attachments.
    The logic is that the Application would generate the attachment file on the Application Server.
    Then a database package uses Oracle's utl_http package/procedures(more specifically utl_http.request_pieces where the single argument is a URL) to pick up the file from the Application Server via URL, attach the file and send the email.
    Exchange and Relay Server is also set in the Application.
    The problem is that the folder containing the folder which stores the attachments is having user authentication set.
    Example : The main folder is /apps/interface, this folder requires a valid user when it is accessed via URL on a web browser.
    Alias created in httpd.conf
    Alias /int-dir/ "/apps/interface/"
    The folder /apps/interface/email/ is the folder where the attachment files are generated and stored.
    Application Server : 10.12.213.21
    Database Server : 10.12.213.22
    Email Server : 10.12.213.44
    Configuration as per httpd.conf
    Alias /int-dir/ "/apps/interface/"
    <Location /int-dir/>
    AuthName "Interface folder"
    AuthType Basic
    AuthUserFile "/u01/app/oracle/as10g/oasmid/Apache/Apache/conf/.htpasswd"
    require user scott
    </Location>
    <Location /int-dir/email>
    Options Indexes Multiviews IncludesNoExec
         Order deny,allow
         Deny from all
         Allow from 10.12.213.21
         Allow from 10.12.213.22
         Allow from 10.12.213.44
    </Location>
    Using the above configuration the Application is able to attach the files and send the email, however, when we access the following URL :
    http://10.12.213.21:7778/int-dir/ - it prompts for user authentication
    However if we use the following URL :
    http://10.12.213.21:7778/int-dir/email/ - it does not prompt for user authentication, and all the files in the folder are displayed in the browser.
    I have tried so many things including AllowOverride, .htaccess, but i am not able to get user authentication for the email folder.
    Please help me if you can.
    Thanking you in advance,
    GLad to give any more information that i can.
    dxbrocky

    Thanks for your response.  I fixed the problem by selecting "full site" or "full website" at bottom of the web page.  After making this selection the zoom function returned.  Thanks again for your interest.

  • Calling a webservice from Pl/SQL

    Hi,
    I have created a function to call a webservice but I am getting the following error
    ORA-20000: soap:Client - System.Web.Services.Protocols.SoapException: Server
    did not recognize the value of HTTP Header SOAPAction: ConversionRate.
    at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
    at
    System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage
    message)
    at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
    at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,
    HttpContext context, HttpRequest request, HttpResponse response, Boolean&amp;
    abortProcessing)
    ORA-06512: at "APPS.SOAP_API", line 54
    ORA-06512: at "APPS.SOAP_API", line 81
    ORA-06512: at "APPS.PKG_MY_WEBSERVICE", line 12
    The Packages code are as follow:
    CREATE OR REPLACE PACKAGE soap_api AS
    TYPE t_request IS RECORD (
    method VARCHAR2(256),
    namespace VARCHAR2(256),
    body VARCHAR2(32767),
    envelope_tag VARCHAR2(30)
    TYPE t_response IS RECORD
    doc XMLTYPE,
    envelope_tag VARCHAR2(30)
    FUNCTION new_request(p_method IN VARCHAR2,
    p_namespace IN VARCHAR2,
    p_envelope_tag IN VARCHAR2 DEFAULT 'SOAP-ENV')
    RETURN t_request;
    PROCEDURE add_parameter(p_request IN OUT NOCOPY t_request,
    p_name IN VARCHAR2,
    p_type IN VARCHAR2,
    p_value IN VARCHAR2);
    FUNCTION invoke(p_request IN OUT NOCOPY t_request,
    p_url IN VARCHAR2,
    p_action IN VARCHAR2)
    RETURN t_response;
    FUNCTION get_return_value(p_response IN OUT NOCOPY t_response,
    p_name IN VARCHAR2,
    p_namespace IN VARCHAR2)
    RETURN VARCHAR2;
    END soap_api;
    CREATE OR REPLACE PACKAGE BODY soap_api AS
    FUNCTION new_request(p_method IN VARCHAR2,
    p_namespace IN VARCHAR2,
    p_envelope_tag IN VARCHAR2 DEFAULT 'SOAP-ENV')
    RETURN t_request AS
    l_request t_request;
    BEGIN
    l_request.method := p_method;
    l_request.namespace := p_namespace;
    l_request.envelope_tag := p_envelope_tag;
    RETURN l_request;
    END;
    PROCEDURE add_parameter(p_request IN OUT NOCOPY t_request,
    p_name IN VARCHAR2,
    p_type IN VARCHAR2,
    p_value IN VARCHAR2) AS
    BEGIN
    p_request.body := p_request.body||'<'||p_name||' xsi:type="'||p_type||'">'||p_value||'</'||p_name||'>';
    END;
    PROCEDURE generate_envelope(p_request IN OUT NOCOPY t_request,
              p_env IN OUT NOCOPY VARCHAR2) AS
    BEGIN
    p_env := '<'||p_request.envelope_tag||':Envelope xmlns:'||p_request.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/" ' ||
    'xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">' ||
    '<'||p_request.envelope_tag||':Body>' ||
    '<'||p_request.method||' '||p_request.namespace||' '||p_request.envelope_tag||':encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' ||
    p_request.body ||
    '</'||p_request.method||'>' ||
    '</'||p_request.envelope_tag||':Body>' ||
    '</'||p_request.envelope_tag||':Envelope>';
    END;
    PROCEDURE show_envelope(p_env IN VARCHAR2) AS
    i PLS_INTEGER;
    l_len PLS_INTEGER;
    BEGIN
    i := 1; l_len := LENGTH(p_env);
    WHILE (i <= l_len) LOOP
    DBMS_OUTPUT.put_line(SUBSTR(p_env, i, 60));
    i := i + 60;
    END LOOP;
    END;
    PROCEDURE check_fault(p_response IN OUT NOCOPY t_response) AS
    l_fault_node XMLTYPE;
    l_fault_code VARCHAR2(256);
    l_fault_string VARCHAR2(32767);
    BEGIN
    l_fault_node := p_response.doc.extract('/'||p_response.envelope_tag||':Fault',
    'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/');
    IF (l_fault_node IS NOT NULL) THEN
    l_fault_code := l_fault_node.extract('/'||p_response.envelope_tag||':Fault/faultcode/child::text()',
    'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
    l_fault_string := l_fault_node.extract('/'||p_response.envelope_tag||':Fault/faultstring/child::text()',
    'xmlns:'||p_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/').getstringval();
    RAISE_APPLICATION_ERROR(-20000, l_fault_code || ' - ' || l_fault_string);
    END IF;
    END;
    FUNCTION invoke(p_request IN OUT NOCOPY t_request,
    p_url IN VARCHAR2,
    p_action IN VARCHAR2)
    RETURN t_response AS
    l_envelope VARCHAR2(32767);
    l_http_request UTL_HTTP.req;
    l_http_response UTL_HTTP.resp;
    l_response t_response;
    BEGIN
    generate_envelope(p_request, l_envelope);
    show_envelope(l_envelope);
    l_http_request := UTL_HTTP.begin_request(p_url, '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(l_envelope));
    UTL_HTTP.set_header(l_http_request, 'SOAPAction', p_action);
    UTL_HTTP.write_text(l_http_request, l_envelope);
    l_http_response := UTL_HTTP.get_response(l_http_request);
    UTL_HTTP.read_text(l_http_response, l_envelope);
    UTL_HTTP.end_response(l_http_response);
    l_response.doc := XMLTYPE.createxml(l_envelope);
    l_response.envelope_tag := p_request.envelope_tag;
    l_response.doc := l_response.doc.extract('/'||l_response.envelope_tag||':Envelope/'||l_response.envelope_tag||':Body/child::node()',
    'xmlns:'||l_response.envelope_tag||'="http://schemas.xmlsoap.org/soap/envelope/"');
    -- show_envelope(l_response.doc.getstringval());
    check_fault(l_response);
    RETURN l_response;
    END;
    FUNCTION get_return_value(p_response IN OUT NOCOPY t_response,
    p_name IN VARCHAR2,
    p_namespace IN VARCHAR2)
    RETURN VARCHAR2 AS
    BEGIN
    RETURN p_response.doc.extract('//'||p_name||'/child::text()',p_namespace).getstringval();
    END;
    END soap_api;
    SHOW ERRORS
    CREATE OR REPLACE PACKAGE pkg_my_webservice IS
    FUNCTION call_myfunction(vp_parameter1 VARCHAR2,vp_parameter2 VARCHAR2) RETURN VARCHAR2;
    END pkg_my_webservice;
    CREATE OR REPLACE PACKAGE BODY pkg_my_webservice IS
    vg_funciton_fnc VARCHAR2(256):='ConversionRate';
    vg_ws_address VARCHAR2(255):='http://www.webservicex.net/CurrencyConvertor.asmx';
    FUNCTION call_myfunction(vp_parameter1 VARCHAR2,vp_parameter2 VARCHAR2)
    RETURN VARCHAR2 AS
    ol_req soap_api.t_request;
    ol_resp soap_api.t_response;
    BEGIN
    ol_req:=soap_api.new_request(vg_funciton_fnc,'xmlns="'||vg_ws_address||'"');
    soap_api.add_parameter(ol_req,'string1','partns:string',vp_parameter1);
    soap_api.add_parameter(ol_req,'string2','partns:string',vp_parameter1);
    ol_resp:=soap_api.invoke(ol_req,vg_ws_address,vg_funciton_fnc);
    RETURN soap_api.get_return_value(ol_resp,'result','xmlns:m="'||vg_ws_address||'"');
    END call_myfunction;
    END pkg_my_webservice;
    -----------------------------------------------------------------------------------------------------------------------------------

    Hi,
    The soap_api package internally uses the utl_http api. I used the utl_http package directly and it works for me. Below is the code for the call, you will have to substitute the variables to suit your setup..
    Hope this Helps
    Thanks
    CREATE OR REPLACE FUNCTION get_webservice_dets(p_emp_number IN VARCHAR2
    ,p_eff_date IN DATE)
    RETURN VARCHAR2
    IS
    lc_proc VARCHAR2(50) := 'get_webservice_dets';
    ln_error_stg NUMBER := 0;
    lc_eff_date VARCHAR2(50) := NULL;
    soap_request VARCHAR2(32767);
    soap_respond VARCHAR2(32767);
    -- HTTP variables
    req utl_http.req;
    resp utl_http.resp;
    -- Store the Webservice URL in a Profile Option and change for each environment
    lc_wsdl_url VARCHAR2(32767) := FND_PROFILE.VALUE('XXERP_WEBSRVC_URL');
    -- return Values
    lc_retval VARCHAR2(32767);
    lc_response VARCHAR2(32767);
    lc_xml_ext_str VARCHAR2(100) := '/env:Envelope/env:Body/OutputParameters/';
    lc_xml_ext_unit VARCHAR2(50) := '/text()';
    lc_xmlns_ns1_url VARCHAR2(240) := 'xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/APPS/XXERP_SOA_HCM_PKG/GET_SUPERVISOR_NO/"';
    lc_xmlns_env_url VARCHAR2(240) := 'xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"';
    lc_xmlns_xsi_url VARCHAR2(240) := 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"';
    lc_xmlns_url VARCHAR2(240) := 'xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/APPS/XXERP_SOA_HCM_PKG/GET_SUPERVISOR_NO/"';
    lc_xml_namespace VARCHAR2(5000) := lc_xmlns_env_url||' '||lc_xmlns_xsi_url||' '||lc_xmlns_url;
    lc_xmlns_soap_url VARCHAR2(240) := 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"';
    lx_Response XMLTYPE;
    BEGIN
    ln_error_stg := 10;
    IF NVL(lc_wsdl_url,'X') <> 'X' THEN
    -- Format the date received as required by the Webservice i.e. - 'YYYY-MM-DDTHH:MI:SS+01:00'
    lc_eff_date := REPLACE(TRIM(TO_CHAR(TRUNC(p_eff_date),'YYYY-MM-DD HH:MI:SS')),' ','T')||'+01:00';
    -- Form a SOAP Envelope - Exact envelope can be obtained by invoking the above EndPoint URL in a browser session with required
    -- parameters and then clicking on the XML Source
    soap_request:= '<soap:Envelope '||lc_xmlns_soap_url||'>
    <soap:Body '||lc_xmlns_ns1_url||'>
    <ns1:InputParameters>
    <ns1:P_EMPLOYEE_NUMBER>'||p_emp_number||'</ns1:P_EMPLOYEE_NUMBER>
    <ns1:P_DATE>'||lc_eff_date||'</ns1:P_DATE>
    </ns1:InputParameters>
    </soap:Body>
    </soap:Envelope>';
    -- Initiate the HTTP request, don't forget to pass in the POST and HTTP/1.1
    req := UTL_HTTP.BEGIN_REQUEST(lc_wsdl_url, 'POST','HTTP/1.1');
    ln_error_stg := 20;
    -- Set the HTTP Request Headers
    UTL_HTTP.SET_HEADER(req, 'Content-Type', 'text/xml'); -- since we are dealing with plain text in XML documents
    ln_error_stg := 40;
    UTL_HTTP.SET_HEADER(req, 'Content-Length', LENGTH(soap_request));
    ln_error_stg := 50;
    -- Set the SOAP Action to the Operation Name
    -- The function Name <getSupervisorID> should match the Webservice Operation Name in SOA
    UTL_HTTP.SET_HEADER(req, 'SOAPAction','getSupervisorID'); -- required to specify this is a SOAP communication
    ln_error_stg := 60;
    -- Append the SOAP Envelope to the HTTP request Header
    UTL_HTTP.WRITE_TEXT(req, soap_request);
    ln_error_stg := 70;
    -- Fetch the HTTP response from the Webservice - This will contain the SOAP Envelope response
    -- that needs to be processed downstream
    resp := UTL_HTTP.GET_RESPONSE(req);
    ln_error_stg := 80;
    -- Extract the HTTP response and store in a String Variable
    -- READ_TEXT is a specific method exposed to read the SOAP envelope returned from Webservice
    -- READ_LINE will read the entire HTML response back from the Server..
    UTL_HTTP.READ_TEXT(resp, lc_retval);
    ln_error_stg := 90;
    -- Create an XML Document from the String returned by the HTTP response..
    lx_Response := SYS.XMLTYPE.CREATEXML(lc_retval);
    ln_error_stg := 110;
    -- If the response is not null then extract the string value of the required output parameter
    -- the env: tag needs to be qualified with a corresponding namespace.
    IF lx_Response IS NOT NULL THEN
    lc_response := lx_Response.extract(lc_xml_ext_str||'PERSON_ID'||lc_xml_ext_unit,lc_xml_namespace).getstringval();
    ELSE
    DBMS_OUTPUT.PUT_LINE('XMLTYPE Doc returns NULL !!');
    lc_response := NULL;
    END IF;
    ln_error_stg := 120;
    -- End the response, otherwise you get
    -- UTL_HTTP.TOO_MANY_REQUESTS exception after 5 tries
    UTL_HTTP.END_RESPONSE(resp);
    ELSE
    DBMS_OUTPUT.PUT_LINE('Web Service URL not populated, please provide a value for the Profile Option XXERP: Web Service URL');
    lc_response := NULL;
    END IF;
    RETURN lc_response;
    EXCEPTION
    WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
    UTL_HTTP.END_RESPONSE(resp);
    RETURN NULL;
    WHEN UTL_HTTP.END_OF_BODY THEN
    UTL_HTTP.END_RESPONSE(resp);
    RETURN NULL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR @'||ln_error_stg||': '||SQLERRM);
    UTL_HTTP.END_RESPONSE(resp);
    RETURN NULL;
    END get_webservice_dets;

  • How to get digital signature for Google Map geocoding V3 in PL/SQL?

    Hi, Gurus:
        Could anyone provide me an example about how to generate digital signature for Google Maps service v3 in PL/SQL? We tried to upgrade our program using Google maps service from v2 to v3. We are using PL/SQl on background to send request to Google for geocoding. We found some sample code to register with digital signature, but none of them is based on PL/SQl. Notice I used Google business client ID "gme-XXX" and wallet.
    https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures
    Google Maps API - more URL signing samples
    Here is my code for V2. I notice in order to get signature, I need to use HMAC-SHA1 algorithm.
    procedure Get_Geocoding(P_s_Address in varchar2, P_s_Geocoding out varchar2, P_n_accuracy out number, P_b_success out boolean) is
      l_address varchar2(4000);
      l_url varchar2(32000);
      l_response varchar2(3200);
      n_first_comma number;
      n_second_comma number;
      n_level_length number;
    BEGIN
      /* TODO implementation required */
      l_address:=APEX_UTIL.URL_ENCODE(P_s_Address);
      l_address := replace(l_address,' ','+');
      l_url := 'http://maps.google.com/maps/geo?q='||l_address||'&'||'output=csv'||'&'||'client=gme-XXX';
    l_response := utl_http.request(l_url, APEX_APPLICATION.G_PROXY_SERVER, '/u02/app/oracle/admin/apexsb/wallet', 'XXXXXXXX');
      n_level_length:=0;
      n_first_comma:=instr(l_response,',',1,1);
      n_second_comma:=instr(l_response,',',1,2);
      n_level_length:=n_second_comma-n_first_comma-1;
      P_n_accuracy:=0;
      if n_level_length>0 then
      P_n_accuracy:=to_number(substr(l_response,n_first_comma+1, n_level_length));
      end if;
      l_response:=substr(l_response,instr(l_response,',',1,2)+1);
      --dbms_output.put_line('In function: l_response ='||l_response);
      P_s_Geocoding:=l_response;
      if (P_s_Geocoding<>'0,0') then
      P_b_success:=true;
      --dbms_output.put_line('true');
      else
      P_b_success:=false;
      --dbms_output.put_line('false');
      end if;
    END;
    Thanks!

    Hi, guys:
        I tried to generate digital signature for Google map service
         Maps for Business: Generating Valid Signatures - YouTube
        Generating an HMAC-SHA-1 Signature Using Only PL/SQL
          OAuth and the PL/SQL | Data Warehouse in the Cloud
       but I got error message from Google:
    Unable to authenticate the request. Provided 'signature' is not valid for the provided client ID. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth
       I think there is something wrong with my code to generate signature, as if I remove the part regarding client and signature, it will work, can anyone help me on this problem?
    /*Procedure Get_Geocoding is used to get geocoding with accuracy level for V3 business account, you can find Google map digital signature descrirption from
    https://developers.google.com/maps/documentation/business/webservices/auth#digital_signatures
    if geocoding is 0,0, procedure returns false to indicate failure of get geocoding*/
    procedure Get_Geocoding2(P_s_Address in varchar2, P_s_Geocoding out varchar2, P_n_accuracy out number, P_b_success out boolean) is
      --private key for Google business account, this is provided by Google with client name.
      l_private_key_src varchar2(200):='xxxxxxxxxxxxxxxxxxx';
      l_private_key_b64_alter varchar2(200):= translate(l_private_key_src,'-_','+/');
      l_private_key_bin raw(2000);
      l_client_name varchar2(100):='gme-xxx';
      l_signature_mac raw(2000);
      l_signature_b64 varchar2(200);
      l_signature_b64_alter_back varchar2(200);
      l_Google_service_domain varchar2(200):='http://maps.googleapis.com';
      l_address varchar2(4000);
      l_url varchar2(32000);
      l_path varchar2(32000);
      l_response varchar2(32000);
      l_page UTL_HTTP.HTML_PIECES;
      n_actual_length number;
      json_obj json;
      json_tempobj json;
      jl_listOfValues json_list;
      json_geom_obj json;
      json_loc json;
      l_lat  VARCHAR2(40);
      l_lng  VARCHAR2(40);
      l_status VARCHAR2(255);
      json_accuracy json;
      --temp_string varchar2(10000);
      n_first_comma number;
      n_second_comma number;
      n_level_length number;
      BEGIN
    /* TODO implementation required */
    l_private_key_bin := utl_encode.base64_decode(UTL_I18N.string_to_raw(l_private_key_b64_alter, 'AL32UTF8'));
    l_address:=APEX_UTIL.URL_ENCODE(P_s_Address);
    --dbms_output.put_line(l_address);
    l_address := replace(l_address,' ','+');
    l_path := '/maps/api/geocode/json?address='||l_address||'&'||'sensor=true';
    dbms_output.put_line(l_path);
    l_signature_mac :=DBMS_CRYPTO.mac(UTL_I18N.string_to_raw(l_path, 'AL32UTF8'), DBMS_CRYPTO.hmac_sh1,l_private_key_bin);
    l_signature_b64:= UTL_RAW.cast_to_varchar2(UTL_ENCODE.base64_encode(l_signature_mac));
    l_signature_b64_alter_back:=translate(l_signature_b64,'+/','-_');
    dbms_output.put_line(l_signature_b64_alter_back);
    --get response from Google map service
    l_url:=l_Google_service_domain||l_path||'&client='||l_client_name||'&signature='||l_signature_b64_alter_back;
    --l_url:=l_Google_service_domain||l_path;
    dbms_output.put_line(l_url);
    l_page:=utl_http.request_pieces( l_url, 99999);
    for i in 1..l_page.count loop
    l_response:=l_response||l_page(i);
    end loop;
    n_actual_length:=length(l_response);
    dbms_output.put_line(n_actual_length);
    dbms_output.put_line(l_response);
    --parse JSON result
    json_obj:=new json(l_response);
    l_status := json_ext.get_string(json_obj, 'status');
    IF l_status = 'OK' then
    jl_listOfValues := json_list(json_obj.get('results'));
    json_tempobj := json(jl_listOfValues.get(1));
    json_geom_obj := json(json_tempobj.get(3));
    json_loc := json_ext.get_json(json_geom_obj, 'location');
    l_lat := to_char(json_ext.get_number(json_loc, 'lat'));
    l_lng := to_char(json_ext.get_number(json_loc, 'lng'));
    P_s_Geocoding:=l_lat||','||l_lng;
    dbms_output.put_line('##########'||P_s_Geocoding);
    case json_ext.get_string(json_geom_obj, 'location_type')
    when 'ROOFTOP' then P_n_accuracy:=9;
    when 'RANGE_INTERPOLATED' then P_n_accuracy:=7;
    when 'GEOMETRIC_CENTER' then P_n_accuracy:=5;
    else P_n_accuracy:=3;
    end case;
    P_b_success:=true;
    else
    P_b_success:=false;
    P_n_accuracy:=0;
    P_s_Geocoding:='0,0';
    end if;
      END;

Maybe you are looking for