3 Replies Latest reply on Apr 20, 2016 8:59 AM by harri.hytonen-javanet

    Problem with optional modifiers

    rhardey

      I have the following setup for a web service:

       

      begin

         ords.enable_schema(p_enabled => true

                           ,p_schema => 'XXXORDS'

                           ,p_url_mapping_type => 'BASE_PATH'

                           ,p_url_mapping_pattern => 'xxx'

                           ,p_auto_rest_auth => true);

         

         ords.create_service (

            p_module_name => 'cfs'

           ,p_base_path   => '/cfs/'

           ,p_pattern     => 'parties/:pn?'

           ,p_source      => 'select * from table(ords_parties_ws.get_parties(:current_user, :pn))'

         );

         commit;

      end;

      /

       

      When I call this web service, using either one of the following URLs, I get a 404: Not found.  If I remove the '?' from the definition above then the second URL works just fine.  This is not how I thought optional modifiers worked. What am I missing?

       

      https://server:port/ords/xxx/cfs/parties/

      https://server:port/ords/xxx/cfs/parties/12345

        • 1. Re: Problem with optional modifiers
          harri.hytonen-javanet

          I have the same problem. Any ideas what goes wrong? I'm evaluating ORDS suitability for our needs and this seems to be an issue. '*' modifier works as documented, but not '?'. ORDS version 3.0.4.60.12.48 and Enterpise Server 12.1.0

          • 2. Re: Problem with optional modifiers
            rhardey

            Hi Harri,

             

            I got my information about optional parameters from this link: https://blog.cdivilly.com/2015/03/10/route-patterns/, and then allowed myself to be misled by the link to route patterns pointed to by that blog post: http://download.oracle.com/otn/java/ords/javadocs/3.0/plugin-api/route-patterns.html

             

            Despite the very first example on the second link showing a route pattern example of '/objects/:object/:id?', this is not allowed in ORDS.  The first blog post has the statement 'In fact it is illegal to have the query string delimiter (?) in a route pattern.', which I originally missed. After logging an SR with Oracle they set me straight.  Annoyingly the ords.create_service() call accepts '?' characters without complaint but the template is invalid, hence the 404s.

             

            So basically the solution is to have two templates for the scenario described in my question above, e.g.:

             

            ords.define_template(p_module_name => 'cfs'

            ,p_pattern     => 'parties/'

            ,p_comments    => '');

             

            ords.define_template(p_module_name => 'cfs'

            ,p_pattern     => 'parties/:pn/'

            ,p_comments    => '');

             

            This works out OK, just doubling the number of templates and handlers that I was expecting to use, but on the other hand allowing me to set up different source types for the GET handlers on each, e.g. the first one as a 'json/collection', the second as 'json/item', allowing different presentations.

             

            Hope that helps,

            Ryan.

            • 3. Re: Problem with optional modifiers
              harri.hytonen-javanet

              Hi Ryan,

               

              Thanks for the solution. I was also following the same (2nd) link with the misleading content, very odd.

               

              BR,

              Harri