APEX_WEB_SERVICE.PARSE_XML

Ok.
I have made a RESTFul web services call to the Google Maps API to calculate the distance between 2 post codes using apex_web_service.make_rest_request and I get the response I am after which is some XML like:
<?xml version="1.0" encoding="UTF-8"?>
<DistanceMatrixResponse>
<status>OK</status>
<origin_address>Random Town, Random City, Post Code, UK</origin_address>
<destination_address>Random Town 2, Random County, UK</destination_address>
<row>
  <element>
   <status>OK</status>
   <duration>
    <value>11455</value>
    <text>1 hours 27 mins</text>
   </duration>
   <distance>
    <value>78951</value>
    <text>345 mi</text>
   </distance>
  </element>
</row>
</DistanceMatrixResponse>
I then convert this into a XMLTYPE in the hope that I can use APEX_WEB_SERVICE.PARSE_XML to extract a particular node. This is where I am struggling a bit. Can anyone help me figure out how I would extract the value "345 mi" from the XML using APEX_WEB_SERVICE.PARSE_XML
I have had a look in the documentation but the example provided does not work.
Cheers for any help.
Duncs

That's what I thought and I was playing around with it last night.
I have just tried your suggestion and it still is returning no data. The entire routine is:
SET SERVEROUTPUT ON
DECLARE
   lv_ws_retval           CLOB;
   lv_ws_retval_xmltype   XMLTYPE;
   lv_distance            VARCHAR2 (32000);
BEGIN
   lv_ws_retval           :=
      apex_web_service.make_rest_request
         p_url           => 'http://maps.googleapis.com/maps/api/distancematrix/xml'
       , p_http_method   => 'GET'
       , p_parm_name     => apex_util.string_to_table ('origins:destinations:sensor:units')
       , p_parm_value    => apex_util.string_to_table ('Vancouver+BC:San+Francisco:false:imperial')
   dbms_output.put_line (lv_ws_retval);
   lv_ws_retval_xmltype   := xmltype (lv_ws_retval);
   lv_distance := apex_web_service.parse_xml (lv_ws_retval_xmltype, '//DistanceMatrixResponse/row/distance/text/text()');
   dbms_output.put_line ('**' || lv_distance || '**');
EXCEPTION
   WHEN OTHERS
   THEN
      dbms_output.put_line (SQLERRM);
END;
If you run this code, you will see that the value of lv_distance is still NULL.
Cheers for any more help you can be.
Regards
Duncs

Similar Messages

  • Problem with apex_web_service.parse_xml

    Hi,
    i made a request to a webservice to get data from an external source via the procedure apex_web_service.make_request. The request works fine and also the apex_web_service.parse_xml when the the SOAP response of the request is not very great (i.e. 20 kB). But when the response i.e. is about 29 kB i get the error ORA-06503 in the procedure apex_web_service.parse_xml.
    Has anybody an idea what's wrong?
    Best regards,
    Martin

    Hi,
    i found the problem :-)
    I used the function apex_web_service.parse_xml to parse the SOAP response. The return datatype of this function is VARCHAR2. Therefore i get the error when the return value overflows.
    Now i use the function apex_web_service.parse_xml_clob and it works fine.
    Regards,
    Martin

  • Problem with apex_web_service.make_request after Upgrade to 4.1.1.00.23

    Hi,
    i upgraded the APEX environment from 4.1 to 4.1.1.00.23 via p13331096_112020_Generic.zip.
    And now i get the error 'ORA-06503: PL/SQL: Function returned without value' when calling the function apex_web_service.make_request.
    I made no changes to the input parameter when calling the function apex_web_service.make_request. They are exact the same as in APEX 4.1.
    Has anybody an idea? - it's very urgent.
    Thanks in advance and best Regards,
    Martin

    Martin:
    Thank you for reporting the issue. As Patrick pointed out, it is unfortunate that there is deficient error handling in apex_web_service, which hopefully will be improved in the future. I created the following test case, and have not been able to reproduce the issue you reported.
    declare
        l_envelope  CLOB;
        l_xml       XMLTYPE;
        l_temp      varchar2(4000);
    BEGIN
        l_envelope := '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
       <soapenv:Header/>
       <soapenv:Body>
          <tem:FahrenheitToCelsius>
             <tem:Fahrenheit>71</tem:Fahrenheit>
          </tem:FahrenheitToCelsius>
       </soapenv:Body>
    </soapenv:Envelope>';
        l_xml := apex_web_service.make_request(
                    p_url               => 'http://www.w3schools.com/webservices/tempconvert.asmx',
                    p_action            => 'http://tempuri.org/FahrenheitToCelsius',
                    p_envelope          => l_envelope
        l_temp := apex_web_service.parse_xml(l_xml,'//FahrenheitToCelsiusResponse/FahrenheitToCelsiusResult/text()','xmlns="http://tempuri.org/"');
        dbms_output.put_line('71 fahrenheit is '||l_temp||' celsius.');
    END;
    /The same code works on both 4.1.0.00.32 and 4.1.1.00.23. The error you got is kind of cryptic, numeric or value error. If you can provide any other details about how your use of apex_web_service.make_request is different than the test case above, it would be appreciated.
    Regards,
    Jason

  • Slow extraction in big XML-Files with PL/SQL

    Hello,
    i have a performance problem with the extraction from attributes in big XML Files. I tested with a size of ~ 30 mb.
    The XML file is a response of a webservice. This response include some metadata of a document and the document itself. The document is inline embedded with a Base64 conversion.  Here is an example of a XML File i want to analyse:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
          <ns2:GetDocumentByIDResponse xmlns:ns2="***">
             <ArchivedDocument>
                <ArchivedDocumentDescription version="1" currentVersion="true" documentClassName="Allgemeines Dokument" csbDocumentID="***">
                   <Metadata archiveDate="2013-08-01+02:00" documentID="123">
                      <Descriptor type="Integer" name="fachlicheId">
                         <Value>123<Value>
                      </Descriptor>
                      <Descriptor type="String" name="user">
                         <Value>***</Value>
                      </Descriptor>
                      <InternalDescriptor type="Date" ID="DocumentDate">
                         <Value>2013-08-01+02:00</Value>
                      </InternalDescriptor>
                      <!-- Here some more InternalDescriptor Nodes -->
                   </Metadata>
                   <RepresentationDescription default="true" description="Description" documentPartCount="1" mimeType="application/octet-stream">
                      <DocumentPartDescription fileName="20mb.test" mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" hashValue=""/>
                   </RepresentationDescription>
                </ArchivedDocumentDescription>
                <DocumentPart mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" representationNumber="0">
                   <Data fileName="20mb.test">
                      <BinaryData>
                        <!-- Here is the BASE64 converted document -->
                      </BinaryData>
                   </Data>
                </DocumentPart>
             </ArchivedDocument>
          </ns2:GetDocumentByIDResponse>
       </soap:Body>
    </soap:Envelope>
    Now i want to extract the filename and the Base64 converted document from this XML response.
    For the extraction of the filename i use the following command:
    v_filename := apex_web_service.parse_xml(v_xml, '//ArchivedDocument/ArchivedDocumentDescription/RepresentationDescription/DocumentPartDescription/@fileName');
    For the extraction of the binary data i use the following command:
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    My problem is the performance of this extraction. Here i created some summary of the start and end time for the commands:
    Start Time
    End Time
    Difference
    Command
    10.09.13 - 15:46:11,402668000
    10.09.13 - 15:47:21,407895000
    00:01:10,005227
    v_filename_bcm := apex_web_service.parse_xml(v_xml, '//ArchivedDocument/ArchivedDocumentDescription/RepresentationDescription/DocumentPartDescription/@fileName');
    10.09.13 - 15:47:21,407895000
    10.09.13 - 15:47:22,336786000
    00:00:00,928891
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    As you can see the extraction of the filename is slower then the document extraction. For the Extraction of the filename i need ~01
    I wonder about it and started some tests.
    I tried to use an exact - non dynamic - filename. So i have this commands:
    v_filename := '20mb_1.test';
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    Under this Conditions the time for the document extraction soar. You can see this in the following table:
    Start Time
    End Time
    Difference
    Command
    10.09.13 - 16:02:33,212035000
    10.09.13 - 16:02:33,212542000
    00:00:00,000507
    v_filename_bcm := '20mb_1.test';
    10.09.13 - 16:02:33,212542000
    10.09.13 - 16:03:40,342396000
    00:01:07,129854
    v_clob := apex_web_service.parse_xml_clob(v_xml, '//ArchivedDocument/DocumentPart/Data/BinaryData/text()');
    So i'm looking for a faster extraction out of the xml file. Do you have any ideas? If you need more informations, please ask me.
    Thank you,
    Matthias
    PS: I use the Oracle 11.2.0.2.0

    Although using an XML schema is a good advice for an XML-centric application, I think it's a little overkill in this situation.
    Here are two approaches you can test :
    Using the DOM interface over your XMLType variable, for example :
    DECLARE
      v_xml    xmltype := xmltype('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
           <soap:Body> 
              <ns2:GetDocumentByIDResponse xmlns:ns2="***"> 
                 <ArchivedDocument> 
                    <ArchivedDocumentDescription version="1" currentVersion="true" documentClassName="Allgemeines Dokument" csbDocumentID="***"> 
                       <Metadata archiveDate="2013-08-01+02:00" documentID="123"> 
                          <Descriptor type="Integer" name="fachlicheId"> 
                             <Value>123</Value> 
                          </Descriptor> 
                          <Descriptor type="String" name="user"> 
                             <Value>***</Value> 
                          </Descriptor> 
                          <InternalDescriptor type="Date" ID="DocumentDate"> 
                             <Value>2013-08-01+02:00</Value> 
                          </InternalDescriptor> 
                          <!-- Here some more InternalDescriptor Nodes --> 
                       </Metadata> 
                       <RepresentationDescription default="true" description="Description" documentPartCount="1" mimeType="application/octet-stream"> 
                          <DocumentPartDescription fileName="20mb.test" mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" hashValue=""/> 
                       </RepresentationDescription> 
                    </ArchivedDocumentDescription> 
                    <DocumentPart mimeType="application/octet-stream" length="20971520 " documentPartNumber="0" representationNumber="0"> 
                       <Data fileName="20mb.test"> 
                          <BinaryData> 
                            ABC123 
                          </BinaryData> 
                       </Data> 
                    </DocumentPart> 
                 </ArchivedDocument> 
              </ns2:GetDocumentByIDResponse> 
           </soap:Body> 
        </soap:Envelope>');
      domDoc    dbms_xmldom.DOMDocument;
      docNode   dbms_xmldom.DOMNode;
      node      dbms_xmldom.DOMNode;
      nsmap     varchar2(2000) := 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="***"';
      xpath_pfx varchar2(2000) := '/soap:Envelope/soap:Body/ns2:GetDocumentByIDResponse/';
      istream   sys.utl_characterinputstream;
      buf       varchar2(32767);
      numRead   pls_integer := 1;
      filename       varchar2(30);
      base64clob     clob;
    BEGIN
      domDoc := dbms_xmldom.newDOMDocument(v_xml);
      docNode := dbms_xmldom.makeNode(domdoc);
      filename := dbms_xslprocessor.valueOf(
                    docNode
                  , xpath_pfx || 'ArchivedDocument/ArchivedDocumentDescription/RepresentationDescription/DocumentPartDescription/@fileName'
                  , nsmap
      node := dbms_xslprocessor.selectSingleNode(
                docNode
              , xpath_pfx || 'ArchivedDocument/DocumentPart/Data/BinaryData/text()'
              , nsmap
      --create an input stream to read the node content :
      istream := dbms_xmldom.getNodeValueAsCharacterStream(node);
      dbms_lob.createtemporary(base64clob, false);
      -- read the content in 32k chunk and append data to the CLOB :
      loop
        istream.read(buf, numRead);
        exit when numRead = 0;
        dbms_lob.writeappend(base64clob, numRead, buf);
      end loop;
      -- free resources :
      istream.close();
      dbms_xmldom.freeDocument(domDoc);
    END;
    Using a temporary XMLType storage (binary XML) :
    create table tmp_xml of xmltype
    xmltype store as securefile binary xml;
    insert into tmp_xml values( v_xml );
    select x.*
    from tmp_xml t
       , xmltable(
           xmlnamespaces(
             'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
           , '***' as "ns2"
         , '/soap:Envelope/soap:Body/ns2:GetDocumentByIDResponse/ArchivedDocument/DocumentPart/Data'
           passing t.object_value
           columns filename    varchar2(30) path '@fileName'
                 , base64clob  clob         path 'BinaryData'
         ) x

  • Error in xml parse procedure :

    hi,
    I am trying to read an xml file and insert data into a database table.
    When I compile the code I get the following warnings :
    PL/SQL: Item ignored
    PLS-00201: identifier 'XMLPARSER.PARSER' must be declared
    PL/SQL: Item ignored
    PLS-00201: identifier 'XMLDOM.DOMDOCUMENT' must be declared
    PL/SQL: Item ignored
    PLS-00201: identifier 'DBMS_XMLDOM.DOMELEMENT' must be declar
    PL/SQL: Item ignored
    PLS-00201: identifier 'XMLDOM.DOMDOCUMENT' must be declared
    PL/SQL: Statement ignored
    I have a local 10g se data base installed on my system.
    The code I am using is mentioned below.
    I checked the database and the package xmlparser does not exist. Can someone please help me on this..
    Regards,
    Siddharth
    create or replace procedure domsample3(dir varchar2, inpfile varchar2)
    is
    p xmlparser.parser;
    doc xmldom.DOMDocument;
    docelem dbms_xmldoM.DOMElement;
    procedure printelements(doc xmldom.DOMDocument) is
    nl1 xmldom.DOMNodeList;
    nl2 xmldom.DOMNodeList;
    nl3 xmldom.DOMNodeList;
    nl4 xmldom.DOMNodeList;
    len1 number;
    len2 number;
    len3 number;
    len4 number;
    n1 xmldom.DOMNode;
    n2 xmldom.DOMNode;
    n3 xmldom.DOMNode;
    n4 xmldom.DOMNode;
    nnm xmldom.DOMNamedNodeMap;
    attrname varchar2(1000);
    attrval varchar2(1000);
    account varchar2(100);
    opptyname varchar2(100);
    opptyid varchar2(100);
    begin
    nl1 := xmldom.getElementsByTagName(doc,'Opportunity');
    nl2 := xmldom.getElementsByTagName(doc,'Account');
    nl3 := xmldom.getElementsByTagName(doc,'Name');
    nl4 := xmldom.getElementsByTagName(doc,'OpptyId');
    len1 := xmldom.getLength(nl1);
    len2 := xmldom.getLength(nl2);
    len3 := xmldom.getLength(nl3);
    len4 := xmldom.getLength(nl4);
    for i in 0..len1-1
    loop
    n1 := xmldoc.item(nl1,i);
    n2 := xmldoc.item(nl2,i);
    n3 := xmldoc.item(nl3,i);
    n4 := xmldoc.item(nl4,i);
    dbms_output.put(xmldoc.getNodeName(n2));
    dbms_output.put(xmldoc.getNodeName(n3));
    dbms_output.put(xmldoc.getNodeName(n4));
    n2 := xmldom.getFirstChild(n2);
    n3 := xmldom.getFirstChild(n3);
    n4 := xmldom.getFirstChild(n4);
    account := xmldom.getNodeValue(n2);
    opptyname := xmldom.getNodeValue(n3);
    opptyid := xmldom.getNodeValue(n4);
    insert into synergyOpptyVals values (accountid, opptyname, opptyid);
    end loop;
    end printelements;
    begin
    p := xmlParser.newParser;
    xmlparser.setValidationMode(p,FALSE);
    xmlparser.setBaseDir(p,dir);
    xmlparser.parse(p,dir || '/' || inpfile);
    doc := xmlparser.getDocument(p);
    dbms_output('The elements are: ');
    printElements(doc);
    end;
    /

    Hi,
    i found the problem :-)
    I used the function apex_web_service.parse_xml to parse the SOAP response. The return datatype of this function is VARCHAR2. Therefore i get the error when the return value overflows.
    Now i use the function apex_web_service.parse_xml_clob and it works fine.
    Regards,
    Martin

  • Apex_web_service.make_rest_request: Passing parameters and the content type

    Not sure if I am missing something, but should this API be setting the content type (to application/x-www-url-formencoded) when there are values present for the parameters p_parm_name and p_parm_value.
    The example in the docs is to a yahoo API. I'm not sure about that particular one (see: http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_web_service.htm#BABEDJHJ), and I think it requires an appid (yahoo account), so i just went with the example here:
    http://developer.yahoo.com/yql/guide/yql-code-examples.html#yql_php
    If I run the following from a html file on my desktop it works:
    <form method="POST" action="http://query.yahooapis.com/v1/public/yql">
    <input type="hidden" name="q" value="select * from upcoming.events where location='San Francisco' and search_text='dance'"></input>
    <input type="hidden" name="format" value="json"></input>
    <input type="submit"></input>
    </form>That is, it returns a JSON result.
    The raw HTTP data is as follows:
    POST http://query.yahooapis.com/v1/public/yql HTTP/1.1
    Host: query.yahooapis.com
    Connection: keep-alive
    Content-Length: 110
    Cache-Control: max-age=0
    Origin: null
    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11
    Content-Type: application/x-www-form-urlencoded
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-AU,en;q=0.8,en-US;q=0.6
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
    q=select+fromupcoming.events+where+location%3D%27San+Francisco%27+and+search_text%3D%27dance%27&format=json>
    However, running the following returns nothing: (nothing, as in nothing that depends on the parameters passed in)
    set serveroutput on
    declare
    l_c CLOB;
    begin
      l_c := apex_web_service.make_rest_request(
        p_url => 'http://query.yahooapis.com/v1/public/yql',
        p_http_method => 'POST',
        p_parm_name => apex_util.string_to_table('q:format'),
        p_parm_value => apex_util.string_to_table('select * from upcoming.events where location=''San Francisco'' and search_text=''dance'':json'),
        p_proxy_override => 'http://192.168.1.3:8888');
      dbms_output.put_line(substr(l_c, 1, 4000));
    end;Raw HTTP data:
    POST http://query.yahooapis.com/v1/public/yql HTTP/1.1
    Host: query.yahooapis.com
    Connection: Keep-Alive
    Content-Length: 106
    Connection: close
    q=select+%2A+from+upcoming%2Eevents+where+location%3D'San+Francisco'+and+search_text%3D'dance'&format=json>
    I do note a key difference is that content type isn't being set in the web service API.
    This was just to test a public service. I do note that the above has slighty different request data (percentage encoding on some chars). However, I experienced the same behaviour on a procedure I had written (I can also provide this example test case if you like), which is where I first noticed the issue.
    Using utl_http and setting the content type to application/x-www-url-formencoded, does resolve the issue. However, just thought i'd see the possibility of using the Web service API that is made available.
    Is the example in the docs valid, or am I missing something obvious?
    This is on ApEx 4.1 on the OTN Dev Days VM.
    Thoughts?

    Hi trent,
    I too have had issues with this API , so moved forward with UTL_HTTP API.
    There is something amiss.
    If you change your code to the one below it works.
    SET SERVEROUT ON
    declare
    l_c CLOB;
    l_param varchar2(1000) ;
    begin
    l_param := 'select * from upcoming.events where location=''San Francisco'' '||
            ' and search_text=''dance'''||'&'||'format=json';
    l_c := apex_web_service.make_rest_request(
        p_url => 'http://query.yahooapis.com/v1/public/yql?q='||
            utl_url.escape(l_param)
        ,p_http_method => 'POST'
      dbms_output.put_line(substr(l_c, 1, 4000));
    end;
    /Note the use of UTL_URL.ESCAPE. The call does not work without it.
    I do not use a proxy, so that parameter does not feature in my snippet above.
    Cheers,
    PS: However, the below does not work. So, it appears that the p_parm_name and p_parm_value do not quite work.
    SET SERVEROUT ON;
    declare
    l_c CLOB;
    l_param varchar2(1000) ;
    begin
    l_param := 'select * from upcoming.events where location=''San Francisco'' and search_text=''dance''';
    l_c := apex_web_service.make_rest_request(
        p_url => 'http://query.yahooapis.com/v1/public/yql'
        ,p_http_method => 'POST'
        ,p_parm_name => apex_util.string_to_table('q:format')
        ,p_parm_value => apex_util.string_to_table(utl_url.escape(l_param)||':json')
      dbms_output.put_line(substr(l_c, 1, 4000));
    end;
    / Edited by: Prabodh on Oct 13, 2012 2:04 PM

  • Invoking RESTful Web Service using APEX_WEB_SERVICE.MAKE_REST_REQUEST

    Hello All,
    APEX Version: 4.0.2.00.07
    DB: Oracle 11G R2
    WebServer: EPG
    Wallet info has been configured at APEX Instance Level, so APEX can access SSL enabled sites.
    When I run following code in page process, to make SOAP request to our intranet JIRA instance, everything just works fine.
    DECLARE
         l_envelope CLOB;
         l_xml XMLTYPE;
         lv_faultcode VARCHAR2(4000);
         lv_faultstring VARCHAR2(4000);     
    BEGIN
         l_envelope := '<?xml version="1.0" encoding="UTF-8"?>'
      ||'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:m0="http://beans.soap.rpc.jira.atlassian.com">'
      ||'<SOAP-ENV:Body>'
      ||'  <m:getIssuesFromFilterWithLimit xmlns:m="http://soap.rpc.jira.atlassian.com" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
      ||'            <in0>'||:F_JIRA_TOKEN||'</in0>'
      ||'         <in1>'||HTF.escape_sc(:P4_IN1)||'</in1>'
      ||'         <in2>'||HTF.escape_sc(:P4_IN2)||'</in2>'
      ||'         <in3>'||HTF.escape_sc(:P4_IN3)||'</in3>'     
      ||'  </m:getIssuesFromFilterWithLimit>'
      ||'  </SOAP-ENV:Body>'
         ||'</SOAP-ENV:Envelope>';
         l_xml := APEX_WEB_SERVICE.MAKE_REQUEST(
                                  p_url => 'https://jira.xyz.com/tracker/rpc/soap/jirasoapservice-v2',
                                  p_action => 'https://jira.xyz.com/tracker/rpc/soap/jirasoapservice-v2/getIssuesFromFilterWithLimit',
                                  p_envelope => l_envelope
    END;However If i'm calling a RESTful webserivce using "apex_web_service" API then I always end-up with following error message.
    The webservice was unreachable because either the URL you supplied was invalid, your environment requires a valid proxy server address for HTTP requests, or a wallet needs to be configured for HTTPS requests.Code (RESTful call)
    DECLARE
         lc_response CLOB;
    BEGIN     
         apex_web_service.g_request_headers(1).name := 'Authorization';
         apex_web_service.g_request_headers(1).value := 'Basic '||:F_JIRA_TOKEN_REST;
         lc_response:= APEX_WEB_SERVICE.MAKE_REST_REQUEST(
                                                                     p_url => 'https://jira.xyz.com/tracker/rest/api/2.0.alpha1/search?jql=assignee=John&startAt=1&maxResults=5',
                                                                     p_http_method => 'GET'
    END;As you can see, both requests are made to same server. However during SOAP request I'm not getting any error, but during RESTful request I'm getting error. Can anyone tell me what could be wrong?
    Best Regards,
    Hari

    Hi Hari,
    this was bug 16212066 - apex_web_service make_rest_request doesn't use instance wallet if not specified
    which will be fixed in APEX 4.2.2.
    As a workaround you can specify the p_wallet_path and p_wallet_pwd parameter when calling apex_web_service.make_rest_request.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Using APEX_WEB_SERVICE api

    Hi,
    We are using the apex_web_service api.make_request process to send a message to a web_service. We are currently receiving an immediate response to say that the web service received the message successfully.
    The web service itself then forwards the message on for further processing and when it is completed processing a response message is returned. This is all done aynschronously.
    Has anyone got any ideas/pointers on what we would need to do to access to the response generated as a result of the further processing.
    Regards
    Paul

    Hi Hari,
    this was bug 16212066 - apex_web_service make_rest_request doesn't use instance wallet if not specified
    which will be fixed in APEX 4.2.2.
    As a workaround you can specify the p_wallet_path and p_wallet_pwd parameter when calling apex_web_service.make_rest_request.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Apex_web_service.make_request fails

    Hi,
    Im trying some of the examples here:
    http://download.oracle.com/docs/cd/E17556_01/doc/apirefs.40/e15519/apex_web_service.htm#BABGEIAH
    But I cant get it to work..
    It fails on this part:
    apex_web_service.make_request
    Here is the code:
    declare
    l_envelope CLOB;
    l_xml XMLTYPE;
    BEGIN
    l_envelope := ' <?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:tns="http://www.ignyte.com/whatsshowing"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <tns:GetTheatersAndMovies>
    <tns:zipCode>43221</tns:zipCode>
    <tns:radius>5</tns:radius>
    </tns:GetTheatersAndMovies>
    </soap:Body>
    </soap:Envelope>';
    l_xml := apex_web_service.make_request(
    p_url => ' http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx',
    p_action => ' http://www.ignyte.com/whatsshowing/GetTheatersAndMovies',
    p_envelope => l_envelope
    END;
    you can see the error here:
    http://test.kolonist.dk/sql_error.jpg
    I then thought maybe the ignyte webservice wasnt available, so I tried another which I found here: http://www.service-repository.com/service/overview/2020380455
    l_envelope := '<?xml version="1.0" encoding="utf-8"?>
    <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/">
    <soap:Body>
    <GetHalloweenDay xmlns="http://www.27seconds.com/Holidays/US/Dates/">
    <year>2010</year>
    </GetHalloweenDay>
    </soap:Body>
    </soap:Envelope>';
    l_xml := apex_web_service.make_request(
    p_url => 'http://www.27seconds.com/Holidays/US/Dates/USHolidayDates.asmx',
    p_action => 'http://www.27seconds.com/Holidays/US/Dates/GetHalloweenDay',
    p_envelope => l_envelope
    Same result..
    I also tried with p_action beeing: GetTheatersAndMovies
    And all kinds of different ways to write the url.
    Edited by: bjarkekr on 2010-10-27 08:45
    Edited by: bjarkekr on 2010-10-27 14:41

    Bjarke,
    Your first envelope contains a space character in front of the url's (this is a bug in the example shown in the APEX Documentation).
    The following code is working fine for me:
    declare
    l_envelope CLOB;
    l_xml XMLTYPE;
    BEGIN
    wwv_flow_api.set_security_group_id;
    l_envelope := '<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:tns="http://www.ignyte.com/whatsshowing"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <tns:GetTheatersAndMovies>
    <tns:zipCode>43221</tns:zipCode>
    <tns:radius>5</tns:radius>
    </tns:GetTheatersAndMovies>
    </soap:Body>
    </soap:Envelope>';
    l_xml := apex_web_service.make_request(
    p_url => 'http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx',
    p_action => 'http://www.ignyte.com/whatsshowing/GetTheatersAndMovies',
    p_envelope => l_envelope
    dbms_output.put_line(substr(l_xml.getClobVal(),1,255));
    END;
    Brgds
    Martin
    Edited by: martinbn on Oct 30, 2010 12:20 AM

  • Apex_web_service.make_request throws ORA-29273: HTTP request failed. How to get the soap fault XML?

    I am trying to call a web service using apex_web_service.make_request function.
    It works fine when all the parameters are correct. However, when something is wrong in the request XML, it throws an exception instead of returning the soap:fault message:
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line 1369
    ORA-29269: HTTP server error 500 - Internal Server Error
    ORA-06512: at "APEX_040200.WWV_FLOW_WEBSERVICES_API", line 130
    ORA-06512: at line 37
    I need to get back the soap:fault and parse it to display a proper error message to the users (e.g. what was wrong with the input), yet the call throws an exception instead of returning it.
    I am trying the exact same request from soapUI and it returns me the soap:fault below:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
       <soap:Body>
          <soap:Fault>
             <soap:Code>
                <soap:Value>soap:Receiver</soap:Value>
             </soap:Code>
             <soap:Reason>
                <soap:Text xml:lang="en">Fault occurred while processing.</soap:Text>
             </soap:Reason>
             <soap:Detail>
                <ns1:RegisterFault xmlns:ns1="http://www.exchangenetwork.net/wsdl/register/1">
                   <description xmlns:ns2="http://www.exchangenetwork.net/wsdl/register/1">The security token has expired.</description>
                   <errorCode xsi:type="ns2:RegisterErrorCode" xmlns:ns2="http://www.exchangenetwork.net/wsdl/register/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">E_TokenExpired</errorCode>
                </ns1:RegisterFault>
             </soap:Detail>
          </soap:Fault>
       </soap:Body>
    </soap:Envelope>
    How do I get this back from APEX?
    Thanks!

    Hi,
       I've just run into this.
       If the webservice returns a fault, such as:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>INVALID_REQUESTER_INFO</faultstring></soap:Fault></soap:Body></soap:Envelope>
       then the user gets presented with an unfriendly error message and there's no chance to output a more friendly one.
       The response above is seen when testing the webservice, when run from the Form/Report page, we get something like:
    soap:ServerINVALID_REQUESTER_INFO
    Contact your application administrator.
    OK
       When OK button is clicked everything is rolled back and we don't even get the fault XML.
       It would be good if Apex could be optionally set to not give the unfriendly messages, so that we could code such a message ourselves.
       Unless anybody has a workaround for this, I guess that I'll have to see if I can code this in PLSQL.
    Regards,
    Chris

  • Updated to 10.3.9, QTSS will not start

    A year after updating my OS X Server 10.3 to its final version release, QTSS still refuses to start. Server Admin, either at the colo or on a remote desktop, yields no error message.
    I've been content producing fast-start 3 minute .mp4 and .m4v downloads w/ FCP5 and QT7 Pro, so I haven't really missed streaming, but now I want it back for long form web videos.
    With OS X Server 10.1, .html files enabled remote or in situ setup and launch of QTSS and those files can still be found on my 10.3 Library, but they now appear corrupted. For example, attempting to launch the QTSS Admin index.html file yields the error, "NO FILE EXISTS: /parse_xml.cgi" though it is right there as a peer in the folder" Dropping the start up .html folder into Safari displays two unlabelled text form boxes (presumably user name and password) with a form button with html tags, clearly a corrupted value.
    So, if the mere html files in QTSS are corrupted, no wonder there's something funky going on under the covers for the QTSS GUI in Server Admin.
    My question is not limited to whether anyone else has experienced this after the ultimate OS X 10.3 upgrade and what's the solution, but also whether Apple has a standalone QTSS installer which can restore the functionality I enjoyed beforehand. It would be a burden with all the websites and users I have configured to start over from scratch...especially since there's no guarantee the same fall down in QTSS's ability to start up would happen again once I upgrades to 10.3.9.
    any help?

    Success. I discovered the issue that was preventing QTSS start up.
    The IP Bind tab listed a set of new Class C IP addresses that ARIN forced us to move to last year and which had been properly configured into our network and I had checked the matching address shared in our new web server config.
    However /library/quicktimestreaming/config/streamingserver.xml had not exterminated the obsolete address and I pico'ed in the Terminal to replace these lines
    <LIST-PREF NAME="bindipaddr" >
    <VALUE>old ip</VALUE>
    <VALUE>new ip</VALUE>
    </LIST-PREF>
    with this line, which will now overide whatever's poking in the old ip, probably one of those pesky permanently-burned Net Info DB's that can't be purged despite the reality that servers sometimes need wholesale refreshes to be re-networked:
    <PREF NAME="bindipaddr" >new ip</PREF>

  • Script for parsing xml data and inserting in DB

    Thank you for reading.
    I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
    I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
    Method 1
    Create or replace procedure parse_xml is 
      l_bfile   BFILE; 
      l_clob    CLOB; 
      l_parser  dbms_xmlparser.Parser; 
      l_doc     dbms_xmldom.DOMDocument; 
      l_nl      dbms_xmldom.DOMNodeList; 
      l_n       dbms_xmldom.DOMNode; 
      l_file      dbms_xmldom.DOMNodeList; 
      l_filen       dbms_xmldom.DOMNode; 
      lv_value VARCHAR2(1000); 
       l_ch      dbms_xmldom.DOMNode; 
    l_partname varchar2(100); 
    l_filename varchar2(1000); 
      l_temp    VARCHAR2(1000); 
      TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE; 
      t_tab  tab_type := tab_type(); 
    BEGIN 
      l_bfile := BFileName('DIR1', 'SoftwareParts.xml'); 
      dbms_lob.createtemporary(l_clob, cache=>FALSE); 
      dbms_lob.open(l_bfile, dbms_lob.lob_readonly); 
      dbms_lob.loadFromFile(dest_lob => l_clob,    src_lob  => l_bfile,    amount   => dbms_lob.getLength(l_bfile)); 
      dbms_lob.close(l_bfile);  
      dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY'''); 
      l_parser := dbms_xmlparser.newParser; 
      dbms_xmlparser.parseClob(l_parser, l_clob); 
      l_doc := dbms_xmlparser.getDocument(l_parser); 
        dbms_lob.freetemporary(l_clob); 
      dbms_xmlparser.freeParser(l_parser); 
      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part'); 
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
        l_n := dbms_xmldom.item(l_nl, cur_emp); 
        t_tab.extend; 
        dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname); 
        t_tab(t_tab.last).partname := l_partname; 
        l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName'); 
        FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP 
          l_ch := dbms_xmldom.item(l_file, cur_ch); 
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch)); 
          if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if; 
          t_tab(t_tab.last).filename := lv_value; 
        t_tab.extend; 
       END LOOP; 
       END LOOP; 
        t_tab.delete(t_tab.last); 
      FOR cur_emp IN t_tab.first .. t_tab.last LOOP 
      if t_tab(cur_emp).partname is not null and  t_tab(cur_emp).filename is not null then 
        INSERT INTO tab_software_parts 
        VALUES 
        (t_tab(cur_emp).partname, t_tab(cur_emp).filename); 
        end if; 
      END LOOP; 
      COMMIT; 
      dbms_xmldom.freeDocument(l_doc); 
    EXCEPTION 
      WHEN OTHERS THEN 
        dbms_lob.freetemporary(l_clob); 
        dbms_xmlparser.freeParser(l_parser); 
        dbms_xmldom.freeDocument(l_doc); 
    END; 
    <TWObject className="TWObject">
      <array size="240">
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[30]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[GB]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[40]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[DE]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
      </array>
    </TWObject>

    Reposted as
    Script to parse XML data into Oracle DB

  • TNS timed out error while testing REST service

    4.2
    11g
    Hi There,
    We had a new application which was to get and post data using REST API which connects to an internal server. This works fine when we use the Google Chrome Advance REST application through the browser, but get a TNS timed out when trying through Apex
    Even a simple sql in the SQL workarea in Apex throws the same error
    select utl_http.request( 'http://ourserver.com/api/subscriptions') test
    from dual;
    ORA-29273: HTTP request failed ORA-06512: at &quot;SYS.UTL_HTTP&quot;, line 1130 ORA-12535: TNS:operation timed out
    Any idea, what the issue could be?   Works fine from the browser though using a REST client
    Trying this for the first time.
    thanks,
    Ryan

    Hi Ryan,
    During your installation, did you follow the steps to enable Network Services, which is one of the requirements when using web services in APEX.  You'll find the necessary information in the installation guide.   Also in your utl_http.request call, have you tried specifying a proxy, if one is required?  You might also want to take a look at at apex_web_service API, specifically the make_rest_request function, which might be useful if you're looking to invoke a RESTful Service via PL/SQL in your application.
    Regards,
    Hilary

  • Problem of integrating apex4.1 with bi publisher

    i 'm working on
    linux + 11gR2 apex 4.1 bi 11.1.1.5.0(only installed bi publisher)
    both apex and bi on the same server and same database
    i 'm following this pdf :Integrating Oracle Application Express with BI Publisher
    http://www.oracle.com/technetwork/developer-tools/apex/integrating-apex-with-bi-publisher-169198.pdf
    now i got a problem when login apex using bip's username
    in validate_login function flex_ws_api.make_request always got null
    here is the function :
    create or replace function validate_login(
    p_username in varchar2,
    p_password in varchar2) return boolean
    is
    l_validate varchar2(48);
    l_env clob;
    l_xml xmltype;
    l_ns varchar2(4000) default null;
    l_url varchar2(4000);
    begin
    l_env := '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">
    <soapenv:Header/>
    <soapenv:Body>
    <pub:validateLogin soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <userID xsi:type="xsd:string">'||p_username||'</userID>
    <password xsi:type="xsd:string">'||p_password||'</password>
    </pub:validateLogin>
    </soapenv:Body>
    </soapenv:Envelope>';
    l_url := 'http://'||v('BIPUB_SERVER');
    if v('BIPUB_PORT') is not null then
    l_url := l_url||':'||v('BIPUB_PORT');
    end if;
    l_url := l_url||'/xmlpserver/services/PublicReportService';
    l_xml := flex_ws_api.make_request(
    p_url => l_url,
    p_envelope => l_env);
    l_validate := flex_ws_api.parse_xml(l_xml,'//validateLoginReturn/text()',v('NS'));
    if l_validate = 'true' then
    return true;
    else
    return false;
    end if;
    exception when others then
    return false;
    end validate_login;
    ...... what's wrong???
    thx !!!!!
    Edited by: 901181 on 2011-12-7 下午7:32

    In hopes that someone can give me some guidance, I've duplicated the issue on my apex.oracle.com workspace.
    Workspace: NBPERP
    Username: GUEST
    Password: 12summer3
    Application: 464. Report Demo
    Page 1 - a drop down list with submit will show that a query, when run, will return values.
    Shared Component/Report Layout: LAYOUT TESTER - a simple RTF with some unique text that mimics the table shown on page 1.
    Shared Component/Report Query: TEST REPORT - the same query that is being executed on Page 1. If I click into the query and set the bind variable to "Indy" (no quotes) and then Apply Changes, I can download an XML file with the correct data. If I think click "Test Report", I get a "no data found" (unexpected condition #1). If I click back into the query and set the bind variable, click "Test Report", again, I get a "no data found" message (unexpected condition #2).
    Any help/direction on this problem would be much appreciated.

  • Display BLOB to PDF in a region

    Hello,
    I have this function :
    getblobfile(APEX_WEB_SERVICE.PARSE_RESPONSE_CLOB('RESPONSE','//runReportReturn/reportBytes','xmlns="http://xmlns.oracle.com/oxp/service/PublicReportService"')
    that return a CLOB converted to a BLOB. The BLOB contains a PDF.
    I would like to display this PDF in a region (in Apex page). How can I do ?
    Thanks.

    Take a look at this link, it should help:
    Re: Displaying a pdf stored as a blob
    Sam

Maybe you are looking for