mihir S
mihir S

Reputation: 647

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?

Upvotes: 1

Views: 1891

Answers (2)

john smith
john smith

Reputation: 568

With WSO2 DSS 3.2.1, you can now define your query string parameter as below:

<param name="cid" sqlType="QUERY_STRING"/>

instead of:

<param name="cid" paramType="SCALAR" sqlType="STRING"/>

and your URL should look like:

.../getDetail?cid=101

Upvotes: 0

Bee
Bee

Reputation: 12502

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

You have to edit your resource path as follows.

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

Upvotes: 3

Related Questions