2 Replies Latest reply on Mar 7, 2011 2:39 PM by Roel Hartman

    Using ResourceTemplates to create AnyCharts XML fails...

    Roel Hartman
      I created a Resource Template called "getChartData".
      The GET (Type - Media Resource) is defined as:

      select 'text/x-apex-html', xmlquery( f_getchartdata returning content)
      from dual

      (getchartdata is a procedure spitting out XML). If I run this from straight from the browser, it returns the correct XML structure.
      (Also when I replace that query with just select 'text/x-apex-html', f_getchartdata from dual it works ok).

      Now I want that output to be the input of an AnyChart chart. So in the Region Source of the chart I replace
      XMLFile=http://localhost:7777/apex/getChartData (which should refer to the ResourceTemplate)

      but alas, that doesn't seem to work.

      Because I am not quite sure if XMLCallDate is added as a parameter, I created another Template with that parameter : getChartData?XMLCallDate={dummy}

      Any ideas, clues? Or is this - for one reason or another - never going to work?

      (Because it is related to the APEX Listener and APEX itself I'll cross post it - and will make a cross reference, so it doesn't matter where you post your answer, as long as you do ;-) )

      Thread in APEX Forum : http://forums.oracle.com/forums/thread.jspa?threadID=2186909

        • 1. Re: Using ResourceTemplates to create AnyCharts XML fails...
          Colm Divilly-Oracle
          What is the Content-Type of AnyChart XML data? I doubt it is text/html (which is what the listener converts text/x-apex-html to). I would expect your query needs to be something along the lines of:
          select 'text/xml', f_getchartdata from dual
          replacing 'text/xml' with the correct content type for the AnyChart data. Not sure if this is the cause of your problem though.

          As an aside, the URI Template for your resource is not very 'RESTful'. Typically your URLs should be designed to name resources rather than operations (contrast with RPC/SOAP which name operations not resources). HTTP provides a set of standard operations (POST,GET,PUT,DELETE) that can be used to manipulate resources. Its a small but important change in approach that is required to design APIs that play well with HTTP. In the case of your current design the HTTP request actually looks like:
          GET /apex/getChartData HTTP/1.1
          Note the repetition of 'get'. I highly recommend the book 'RESTful Web Services' by Ruby & Richardson, for more insight on this topic.

          GET /apex/charts/somekindofchart HTTP/1.1
          GET /apex/charts/{chartid} HTTP/1.1
          might be better for your design.
          • 2. Re: Using ResourceTemplates to create AnyCharts XML fails...
            Roel Hartman
            Using the correct Content-Type doesn't help, but returns a better result (XML like).
            The actual issue was the parameter AnyCharts is adding. So the correct Template should be: getChartData?&xmlcalldate={dummy} (notice the & !).
            And indeed, my naming convention could be better...thanks for pointing that out!

            For the actual solution see the thread on the APEX Forum (link in first post of this thread).