Greg March
Greg March

Reputation: 11

WSO2 Data Services Server REST configuration

First post to SO, hopefully, I get it right. :-)

And, new to WSO2DSS...

I'd like to configure WSO2DSS to expose REST services like, for example:

http://localhost/svcendpoint/products
http://localhost/svcendpoint/products/computer
http://localhost/svcendpoint/products/computer/disks

where each url returns a more refined list. I've set up three queries / operations / resources, but I'm not getting the expected results.

I am getting the list for the first, a Axis2 "String index out of range" exception for the second, and a list for the third.

I'm not sure if it is me, a bug, or the wrong way to do this. Any help would be appreciated.

Here is the .dbs file (I can include the exception stacktrace if it will be useful):

<data name="MyDataService">
   <config id="MyDataSource">
      <property name="driverClassName">oracle.jdbc.driver.OracleDriver</property>
      <property name="url">jdbc:oracle:thin:xxxxxx</property>
      <property name="username">xxx</property>
      <property name="password">xxx</property>
   </config>
   <query id="MyCategoriesQuery" useConfig="MyDataSource">
      <sql>select distinct CAT_NM from T_FAM_BLMBRG_DATA_DICT order by CAT_NM</sql>
      <result defaultNamespace="http://test.org" element="categories" rowName="">
         <element column="FLD_MNM_NM" name="FLD_MNM_NM" xsdType="string"/>
         <element column="FLD_ID" name="FLD_ID" xsdType="string"/>
         <element column="DATA_LIC_CAT_NM" name="DATA_LIC_CAT_NM" xsdType="string"/>
         <element column="FLD_DESC_TX" name="FLD_DESC_TX" xsdType="string"/>
         <element column="CAT_NM" name="CAT_NM" xsdType="string"/>
         <element column="FLD_DFN_TX" name="FLD_DFN_TX" xsdType="string"/>
         <element column="FLD_DATYP_NM" name="FLD_DATYP_NM" xsdType="string"/>
         <element column="CRT_USER_ID" name="CRT_USER_ID" xsdType="string"/>
         <element column="CRT_TS" name="CRT_TS" xsdType="string"/>
         <element column="UPD_USER_ID" name="UPD_USER_ID" xsdType="string"/>
         <element column="UPD_TS" name="UPD_TS" xsdType="string"/>
      </result>
   </query>
   <query id="MyCategoryQuery" useConfig="MyDataSource">
      <sql>select * from T_FAM_BLMBRG_DATA_DICT where CAT_NM = :cat</sql>
      <result defaultNamespace="http://test.org" element="entries" rowName="">
         <element column="FLD_MNM_NM" name="FLD_MNM_NM" xsdType="string"/>
         <element column="FLD_ID" name="FLD_ID" xsdType="string"/>
         <element column="DATA_LIC_CAT_NM" name="DATA_LIC_CAT_NM" xsdType="string"/>
         <element column="FLD_DESC_TX" name="FLD_DESC_TX" xsdType="string"/>
         <element column="CAT_NM" name="CAT_NM" xsdType="string"/>
         <element column="FLD_DFN_TX" name="FLD_DFN_TX" xsdType="string"/>
         <element column="FLD_DATYP_NM" name="FLD_DATYP_NM" xsdType="string"/>
         <element column="CRT_USER_ID" name="CRT_USER_ID" xsdType="string"/>
         <element column="CRT_TS" name="CRT_TS" xsdType="string"/>
         <element column="UPD_USER_ID" name="UPD_USER_ID" xsdType="string"/>
         <element column="UPD_TS" name="UPD_TS" xsdType="string"/>
      </result>
      <param name="cat" sqlType="STRING"/>
   </query>
   <query id="MyCategoryFldQuery" useConfig="MyDataSource">
      <sql>select * from T_FAM_BLMBRG_DATA_DICT where CAT_NM = :cat and FLD_ID = :fld</sql>
      <result defaultNamespace="http://test.org" element="names" rowName="">
         <element column="FLD_MNM_NM" name="FLD_MNM_NM" xsdType="string"/>
         <element column="FLD_ID" name="FLD_ID" xsdType="string"/>
         <element column="DATA_LIC_CAT_NM" name="DATA_LIC_CAT_NM" xsdType="string"/>
         <element column="FLD_DESC_TX" name="FLD_DESC_TX" xsdType="string"/>
         <element column="CAT_NM" name="CAT_NM" xsdType="string"/>
         <element column="FLD_DFN_TX" name="FLD_DFN_TX" xsdType="string"/>
         <element column="FLD_DATYP_NM" name="FLD_DATYP_NM" xsdType="string"/>
         <element column="CRT_USER_ID" name="CRT_USER_ID" xsdType="string"/>
         <element column="CRT_TS" name="CRT_TS" xsdType="string"/>
         <element column="UPD_USER_ID" name="UPD_USER_ID" xsdType="string"/>
         <element column="UPD_TS" name="UPD_TS" xsdType="string"/>
      </result>
      <param name="cat" sqlType="STRING"/>
      <param name="fld" sqlType="STRING"/>
   </query>
   <operation name="MyCategoriesService">
      <call-query href="MyCategoriesQuery"/>
   </operation>
   <operation name="MyCategoryService">
      <call-query href="MyCategoryQuery">
         <with-param name="cat" query-param="cat"/>
      </call-query>
   </operation>
   <operation name="MyCategoryFldService">
      <call-query href="MyCategoryFldQuery">
         <with-param name="cat" query-param="cat"/>
         <with-param name="fld" query-param="fld"/>
      </call-query>
   </operation>
   <resource method="GET" path="category">
      <call-query href="MyCategoriesQuery"/>
   </resource>
   <resource method="GET" path="category/{cat}">
      <call-query href="MyCategoryQuery">
         <with-param name="cat" query-param="cat"/>
      </call-query>
   </resource>
   <resource method="GET" path="category/{cat}/{fld}">
      <call-query href="MyCategoryFldQuery">
         <with-param name="cat" query-param="cat"/>
         <with-param name="fld" query-param="fld"/>
      </call-query>
   </resource>
</data>

Upvotes: 1

Views: 916

Answers (1)

poohdedoo
poohdedoo

Reputation: 1268

You need to invoke the service as shown below

http://localhost:9763/services/SERVIVENAME.HTTPEndpoint/RESOURCEPATH/

For example

http://localhost:9763/services/MyDataSource.HTTPEndpoint/category/computer

Please refer [1] for more details

https://docs.wso2.org/display/DSS310/Exposing+Data+as+REST-Style+Resources

Upvotes: 1

Related Questions