2014-04-01 110 views
1

首先發布到SO,希望我能理解。 :-)WSO2數據服務服務器REST配置

而且,新WSO2DSS ...

我想配置WSO2DSS揭露像REST服務,例如:

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

其中每個URL返回一個更精緻的列表。我已經建立了三個查詢/操作/資源,但是我沒有得到預期的結果。

我得到第一個列表,第二個Axis2「字符串索引超出範圍」異常,第三個列表。

我不確定這是我,一個錯誤還是錯誤的方法。任何幫助,將不勝感激。

這裏是.dbs文件(我可以包括異常堆棧跟蹤它是否將是有益的):

<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> 

回答

1

您需要調用的服務如下圖所示

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

例如

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

請參考[1]瞭解更多詳情

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

+0

是的,這就是我正在做的。問題不是服務的調用,而是一些調用導致異常的事實。我發佈的第一個網址是。第二個導致一個例外,第三個作品。查看.dbs中的資源塊,瞭解它們是如何定義的。注意:我輸入的網址是「示例」,實際的網址看起來像是你寫的。 –