Search code examples
wso2wso2-data-services-server

Need to create WSO2 DSS service which can read parameter from url


I have created a simple dss service which by inputing cust_id it gives me the customer data.

I have exposed this webservice as http get resource with the following url GET /services/getCustDetailDSS/getDetail?cid=101

Corrsponding xml code for my service is as follows

<data name="getCustomerDetailDSS" serviceGroup="" serviceNamespace="">
<description/>
<config id="mydb">
    <property name="carbon_datasource_name">mydb</property>
</config>
<query id="get_customer_detail" useConfig="mydb">
    <sql>select identifier,user_status from customer_detail where identifier = :cid</sql>
    <param name="cid" paramType="SCALAR" sqlType="STRING"/>
    <result element="customer">
        <element column="identifier" name="cid" xsdType="xs:string"/>
        <element column="user_status" name="status" xsdType="xs:string"/>
    </result>
</query>
<operation name="get_customer_detail_operation">
    <call-query href="get_customer_detail">
        <with-param name="cid" query-param="identifier"/>
    </call-query>
</operation>
<resource method="GET" path="/getDetail">
    <call-query href="get_customer_detail">
        <with-param name="cid" query-param="cid"/>
    </call-query>
</resource>
</data>

But now i want the dss service to read cust_id from url instead of passing it as a parameter.

i.e i want to hit dss service as GET /services/getCustDetailDSS/cid/101/getDetail

How can i do this in DSS ?

Can anyone provide wat changes i need to do in my dss?


Solution

  • For GET /services/getCustDetailDSS/getDetail/cid/101

    You have to edit your resource path as follows.

    <resource method="GET" path="getDetail/cid/{cid}">