This discussion is archived
5 Replies Latest reply: Dec 13, 2012 2:35 AM by patfmnd RSS

Consuming RESTful web service in Apex app

patfmnd Newbie
Currently Being Moderated
Hi,
I have created a RESTful Web service through an Apex application (4.0) and published as a public web service. Can someone point me to an example of how to then consume that service in another Apex app? The output is straightforward XML that I can retrieve just by pointing the browser to the URL of the service created, but when I go to create the REST Web Reference for the receiving application, I am not sure what to put for the Response Xpath or Response Namespace. The service is meant to just return report records that were created in the REStful Web service with no input required.

The service XML looks like this:
<ROWSET>
<ROW>
<PROJ_ID>132</PROJ_ID>
<PSL_NETID>xxxxxxxx</PSL_NETID>
<PROJECT_TITLE>11g- Oracle Upgrade to RAC 11g</PROJECT_TITLE>
<CUSTOMER>OIT</CUSTOMER>
<DIVISION>EIS</DIVISION>
.
.
.
</ROW>
<ROW>
<PROJ_ID>132</PROJ_ID>
<PSL_NETID>xxxxxx</PSL_NETID>
<PROJECT_TITLE>11g- Oracle Upgrade to RAC 11g</PROJECT_TITLE>
<CUSTOMER>OIT</CUSTOMER>
<DIVISION>CSS</DIVISION>

Any help would be appreciated.

Thanks,
Pat

Edited by: patfmnd on Dec 7, 2012 3:04 AM
  • 1. Re: Consuming RESTful web service in Apex app
    Kiran Expert
    Currently Being Moderated
    Hello Pat,

    The following documentation might help:

    http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex40webservicesevaluationguide-214504.pdf

    OR

    The following demos on the OLL also will help:

    [url http://apex.oracle.com/pls/apex/f?p=44785:24:0:::24:P24_CONTENT_ID,P24_PREV_PAGE:5816,24]Creating and Using a RESTful Web Service with an XML Response

    [url http://apex.oracle.com/pls/apex/f?p=44785:24:0:::24:P24_CONTENT_ID,P24_PREV_PAGE:5817,24]Creating and Using a RESTful Web Service with an XML Response and a Bind Variable


    Hope it helps!
    Regards,
    Kiran
  • 2. Re: Consuming RESTful web service in Apex app
    patfmnd Newbie
    Currently Being Moderated
    Hi,
    Thanks for the reply. The documentation was helpful but I am still unclear as to what I should use for the Xpath.
    My URL I know is correct because I can retireve the data by pointing to it in a browser directly!!

    This is what I have for WEb REference:
    URL -- the URL for the REST report as mentioned above
    No proxy override --
    No basic authentication
    HTTP method -- get
    Output XML
    Repsonse Xpath - /result
    No response namespace
    No input parameters
    REST Output parameters:
    PROJ_ID /PROJ_ID etc. to match below
    <ROWSET>
    <ROW>
    <PROJ_ID>132</PROJ_ID>
    <PSL_NETID>xxxxxxx</PSL_NETID>
    <PROJECT_TITLE>11g- Oracle Upgrade to RAC 11g</PROJECT_TITLE>
    <CUSTOMER>OIT</CUSTOMER>
    </ROW>

    When I test I get---
    ORA-20001: 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.

    I am creating the Web reference in an application on the SAME Apex environment as the Application providing the REST output.

    Appreciate any help I can get!

    Thanks,
    Pat
  • 3. Re: Consuming RESTful web service in Apex app
    patfmnd Newbie
    Currently Being Moderated
    Hi,
    I have made progress in this. I created the RESTful report service in an Apex 4.1 application. (previous attempt was with 4.0 version of Apex)

    I then created a separate application and created a RESTful web service reference that I tested and it was successful in bringing up XML. However in Apex 4.1, when I create a report following the Wizard for creating a report based on that Web service reference I get the error: ORA-31013: Invalid XPATH expression Which I don't know how to get past. The Xpath provided in the Web service reference test gave output below and brought back a result. There was no where during the Report creation to provide an Xpath. Am I missing something or is 4.1 not quite Web service ready??

    This is what I get from the test of the Web service reference in the Apex App from which I want to create a report: (I see in this XML the data I was expecting from the test of the RESTful web service but it looks like the output I get from the Web service test is more like the Report xml itself.)

    <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:htmldb="http://htmldb.oracle.com" xmlns:apex="http://apex.oracle.com"> <head> <title>Author</title>
    <!--[if IE]><link rel="stylesheet" href="/i/css/apex_ie_4_1.css" type="text/css" /><![endif]--> <script type="text/javascript">
    //<![CDATA[
    var apex_img_dir = "/i/", htmldb_Img_Dir = apex_img_dir;
    //]]>
    </script>
    <script src="/i/javascript/apex_4_1.min.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    //<![CDATA[
    apex.security.framebreaker("D");
    //]]>
    </script>
    <!--[if IE]><link rel="stylesheet" href="/i/themes/theme_2/css/theme_4_0_ie.css" type="text/css" /><![endif]--><!--[if IE 6]><link rel="stylesheet" href="/i/themes/theme_2/css/theme_4_0_ie6.css" type="text/css" /><![endif]--><!--[if IE 7]><link rel="stylesheet" href="/i/themes/theme_2/css/theme_4_0_ie7.css" type="text/css" /><![endif]--><!--[if lte IE 6]><div id="outdated-browser">You are using an outdated web browser. For a list of supported browsers, please reference the Oracle Application Express Installation Guide.</div><![endif]-->
    <form action="wwv_flow.accept" method="post" name="wwv_flow" id="wwvFlowForm"><input type="hidden" name="p_flow_id" value="140" id="pFlowId" /><input type="hidden" name="p_flow_step_id" value="1" id="pFlowStepId" /><input type="hidden" name="p_instance" value="6146802068150520" id="pInstance" /><input type="hidden" name="p_page_submission_id" value="1940235134399423" id="pPageSubmissionId" /><input type="hidden" name="p_request" value="" id="pRequest" />
    <div id="header">
    <div id="app-logo"><a href="f?p=140:1:0"></a></div>
    <div id="navbar">
    <div class="navbar-entry">Logout</div>
    </div>
    </div>
    <div id="tabs">
    <div class="frame">
    <div class="bg">
    <div class="tab-holder">
    <div class="first-current">
    <div><span>Author</span></div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <div id="topbar">
    <div class="breadcrumb-region" id="R170908223330421512">
    <div>
    <div id="breadcrumbs">
    <ul class="breadcrumb-list">
    <li class="current">Author</li>
    </ul>
    </div>
    </div>
    </div>
    </div>
    <div id="messages"></div>
    <div id="body">
    <table class="tbl-body" cellspacing="0" cellpadding="0" border="0" summary="">
    <tbody>
    <tr>
    <td class="tbl-main" width="100%">
    <div class="rounded-corner-region" id="books">
    <div class="rc-blue-top">
    <div class="rc-blue-top-r">
    <div class="rc-title">AUTHOR</div>
    <div class="rc-buttons"><button value="Reset" class="button-gray" type="button" id="B170907622885421490"><span>Reset</span></button></div>
    </div>
    </div>
    <div class="rc-body">
    <div class="rc-body-r">
    <div class="rc-content-main">
    <table id="apex_layout_170907030238421484" border="0" class="formlayout" summary="" role="presentation" datatable="0">
    <tr>
    <td align="right"><label for="P1_REPORT_SEARCH" tabindex="999"><a class="optional-w-help" href="javascript:popupFieldHelp('170907422375421487','6146802068150520')" tabindex="999">Search</a></label></td>
    <td colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="170907422375421487" /><input type="text" id="P1_REPORT_SEARCH" name="p_t01" value="" size="30" maxlength="2000" class="text_field" /></td>
    <td align="right"><label for="P1_ROWS" tabindex="999"><a class="optional-w-help" href="javascript:popupFieldHelp('170907508375421490','6146802068150520')" tabindex="999">Display</a></label></td>
    <td colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="170907508375421490" /><select name="p_t02" id="P1_ROWS" size="1" class="selectlist">
    <option value="10">10</option>
    <option value="15" selected="selected">15</option>
    <option value="20">20</option>
    <option value="30">30</option>
    <option value="50">50</option>
    <option value="100">100</option>
    <option value="200">200</option>
    <option value="500">500</option>
    <option value="1000">1000</option>
    <option value="5000">5000</option>
    </select></td>
    <td align="left"></td>
    <td colspan="1" rowspan="1" align="left"><button value="Go" class="button-gray" type="button" id="P1_GO"><span>Go</span></button></td>
    </tr>
    </table>
    <div id="report_170907030238421484_catch">
    <table cellpadding="0" border="0" cellspacing="0" summary="" id="report_books">
    <tr>
    <td></td>
    </tr>
    <tr>
    <td>
    <table cellpadding="0" border="0" cellspacing="0" summary="" class="report-standard">
    <tr>
    <th id="AUTHORID" class="header">
    <div class="rpt-sort">Authorid<img align="absmiddle" src="/i/arrow_up_gray_dark.gif" width="13" height="12" alt="Sort by this column" /></div>
    </th>
    <th id="LNAME" class="header">
    <div class="rpt-sort">Lname</div>
    </th>
    <th id="FNAME" class="header">
    <div class="rpt-sort">Fname</div>
    </th>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">A100</td>
    <td headers="LNAME" class="data">AUSTIN</td>
    <td headers="FNAME" class="data">JAMES</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">A105</td>
    <td headers="LNAME" class="data">ADAMS</td>
    <td headers="FNAME" class="data">JUAN</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">B100</td>
    <td headers="LNAME" class="data">BAKER</td>
    <td headers="FNAME" class="data">JACK</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">F100</td>
    <td headers="LNAME" class="data">FIELDS</td>
    <td headers="FNAME" class="data">OSCAR</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">J100</td>
    <td headers="LNAME" class="data">JONES</td>
    <td headers="FNAME" class="data">JANICE</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">K100</td>
    <td headers="LNAME" class="data">KZOCHSKY</td>
    <td headers="FNAME" class="data">TAMARA</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">M100</td>
    <td headers="LNAME" class="data">MARTINEZ</td>
    <td headers="FNAME" class="data">SHEILA</td>
    </tr>
    <tr class="highlight-row">
    <td headers="AUTHORID" class="data">P100</td>
    <td headers="LNAME" class="data">PORTER</td>
    <td headers="FNAME" cla

    Edited by: patfmnd on Dec 12, 2012 5:59 PM

    Edited by: patfmnd on Dec 12, 2012 6:07 PM
  • 4. Re: Consuming RESTful web service in Apex app
    Mindmap Pro
    Currently Being Moderated
    Hello,

    Have you watched the videos here:
    http://apex.oracle.com/pls/apex/f?p=44785:2:0::NO:RIR::

    By the way, perhaps, you have come across this problem and so you / Kiran can help ...

    I just posted a new thread {message:id=10738980}

    Regards,
    Fateh
  • 5. Re: Consuming RESTful web service in Apex app
    patfmnd Newbie
    Currently Being Moderated
    Thanks Fateh,
    Yes, I had viewed the tutorials and looked at all the documentation. Problem is my case is much simpler and the demos are using external RESTful service examples whereas mine is just trying to use a RESTful service from an Apex report. The strange thing is that I can TEST the Webservice when I build the RESTful Web Service reference but it brings back MORE than what I would expect. It looks like it is bringing back the XML of the report and not just the RESTful service. So it seems there is either a bug in the Apex 4.1 production of a RESTful service from a report or some problem with the retrieval of the Web service. When I open up the URL of the Web service just in a browser window-- it looks fine, but when I open it in the TEST of Web Service REference, it looks strange --with much more XML than I would expect.

    Pat

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points