3 Replies Latest reply on Mar 27, 2013 4:40 PM by RickG

    Restful Webservice -- Page Not Found

      Using the web service wizard in SQL workshop, I have created a simple Restful web service using a GET request of Media Resource Type. The SQL statement gets the mime_type and a blob value from a table via an ID parameter. The code works fine in my standalone environment (apex 4.2 Listener 2.1) but on the Cloud, when I bind the variable :ID and press the test button, it always returns, "Page not Found". Even when I call the ws via APEX_WEB_SERVICE.MAKE_REST_REQUEST, it returns, "Page Not Found".

      The test screen creates the following URL: https://database-xxxxxx.us1.oraclecloudapps.com/apex/export/get/1

      If I run this in the browser, it also returns "Page Not Found". Looking at the URL, it doesn't look correct. Usually, the workspace is also a part of the url (after the /apex/ piece). Here it is missing. However, even when I add it, the error is still "Page Not Found". I have verified that the workspace has Restful web services enabled and I'm logging in with the admin user who has all three SQL Dev permissions granted.

      Has anyone seen this before? I'm I missing some permission or doing something wrong?


        • 1. Re: Restful Webservice -- Page Not Found
          Hilary Farrell-Oracle
          Hi Steve,

          +> The code works fine in my standalone environment (apex 4.2 Listener 2.1)+
          Just to clarify things, Oracle Application Express Listener 2.0.1, which I assume is the version you have installed locally, is the latest Listener release available and is currently running on the Cloud. Oracle Application Listener 2.0 adds support for connecting to more than one database, and includes support for a number of different strategies for routing requests to the appropriate database, each of which is outlined in the Listener Installation and Configuration Guide (see http://docs.oracle.com/cd/E37099_01/doc/doc.20/e25066/config.htm#CBDCHGDF). All strategies rely on examining the request URI and choosing the database based on some kind of match against the URL, and depending on the chosen strategy, the URL will differ.

          +>... when I bind the variable :ID and press the test button, it always returns, "Page not Found".....The test screen creates the following URL: https://database-xxxxxx.us1.oraclecloudapps.com/apex/export/get/1+
          To assist in pinpointing the cause of the error you're seeing, could you please confirm whether the following details match your RESTful service:

          * URI Template: get/{id}
          * Resource Handler Method: GET
          * Resource Handler Source Type: Media Resource
          * Requires Secure Access: No
          * Source (matching the following syntax): select mime_type, blob_column from table_name where no = :id

          NOTE: if you need to set a bind variable for a parameter, then the "Set Bind Variables" option should be used instead of "Test".

          +> Usually, the workspace is also a part of the url (after the /apex/ piece).+
          In your local environment, the requests are being routed via the Path Prefix setting in the RESTful Service URL (see http://docs.oracle.com/cd/E37099_01/doc/doc.20/e25066/config.htm#CBDJIEGH). On your local instance, navigate to Administration > Manage Service, Set Workspace Preferences, and in the SQL Workshop region you'll find the Path Prefix item. The Path Prefix defaults to the short name of the workspace, which is what you're seeing in your URL locally. However, a different routing method is being used on the Cloud, so you will not see the Path Prefix used there.

          Would you mind testing the 'oracle.example.hr' sample RESTful Service in your workspace, and let me know if you experience issues running any of the examples?

          • 2. Re: Restful Webservice -- Page Not Found

            The solution seems crazy but I had the bind variable as :ID. When I changed it to :id, it now works!?

            I wish the listener returned better error messages than "Page not found". The other strange thing I noticed while first testing the HR web services as you suggested is that if you enter a bind variable value that matches a row in the emp table, the web services work. If you do not and no data is returned by the query, you also get "Page not found".


            • 3. Re: Restful Webservice -- Page Not Found
              Steve -

              Just wanted to expand on your comment on the error message for the benefit of others, since the situation is a little more subtle.

              There are actually 2 different error messages you can get back from a SQL source type - Data not found, which happens when a query does not return rows (and seems like a correct way to do it to me) and a message relating to invalid syntax, such as if you try to do a test of a RESTful call with parameters without setting the parameters, i.e., using '{id}' instead of a number. This also seems to make sense.

              If you want more meaningful error messages, at this time, you can use PL/SQL and catch and process errors yourself.

              - Rick Greenwald