1 Reply Latest reply on Jan 15, 2013 11:47 AM by rareddy

    8.2 any dynamic-vdb rest json auto-generate example/guidelines?

    m.ardito

      i've found this example into docs (https://docs.jboss.org/author/display/teiid82final/REST+Service+Through+VDB)

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <vdb name="sample" version="1">

          <property name="UseConnectorMetadata" value="true" />

          <property name="{http://teiid.org/rest}auto-generate" value="true"/>

          <model name="PM1">

              <source name="text-connector" translator-name="loopback" />

               <metadata type="DDL"><![CDATA[

                      CREATE FOREIGN TABLE G1 (e1 string, e2 integer);

                      CREATE FOREIGN TABLE G2 (e1 string, e2 integer);

              ]]> </metadata>

          </model>

          <model name="View" type ="VIRTUAL">

               <metadata type="DDL"><![CDATA[

                  SET NAMESPACE 'http://teiid.org/rest' AS REST;

                  CREATE VIRTUAL PROCEDURE g1Table(IN p1 integer) RETURNS TABLE (xml_out xml) OPTIONS (UPDATECOUNT 0, "REST:METHOD" 'GET', "REST:URI" 'g1/{p1}')

                  AS

                  BEGIN

                      SELECT XMLELEMENT(NAME "rows", XMLATTRIBUTES (g1Table.p1 as p1), XMLAGG(XMLELEMENT(NAME "row", XMLFOREST(e1, e2)))) AS xml_out FROM PM1.G1;

                  END

                  ]]> </metadata>

          </model>

      </vdb>

       

      and i managed to adatp it to use my real model (mysql)

       

      i would like to make it uptput json strings, though, but can't put the docs pieces together... adding "REST:PRODUCES" 'json' is not enough, clearly

       

      is there any example or guideline i can lear from around here.. i know is quite new feature but sounds really interesting...

       

      Thanks

      Marco