Wednesday Jan 15, 2014

Consuming Query and Path Parameter in REST DC

Use Case:

In this blog I will explain on how to configure the REST DC when there are Query and Path Parameters present in the Service that is to be consumed.
The Query and Path parameters in the DC are exposed as method Input Parameters in the DC palette allowing the user for easy Drag and Drop.

JDeveloper Version : 12.1.2

Implementation:

Configuring Query Parameters

Service API Uri:

http://<Server>/SampleApp/resources/rest-deleteservice?name=’Abby’

Scenario Details:
In this Uri ‘name’ is a Query Parameter which will be used to delete a specific record, to expose this follow the below steps

1.    Invoke the Rest DC  and create the connection

2. In the Resources tab, enter the  remaining resource uri without providing the ‘?name=’  as shown below

3. In the Method Details tab select the delete method, and in the URL Parameters panel click on ‘+’ and enter the parameter details.
Provide an Default value which will be invoked whenever the service is loaded

NOTE:
Providing a Valid Default Value becomes crucial when there is a GET with Query Param for which you would like the XSD to be generated by the Jdeveloper itself. 

Configuring Path Parameters


Service Uri:
http://<ServerDetails>/sqlrest/CUSTOMER/7/


Scenario Details:
In the above case ‘7’ is an customer id value based on which the specific customer record will be fetched, so this customer id is dynamic so we will be discussing on how to expose this as an dynamic field in the REST DC


1.    Invoke the Rest DC and create the Connection with Server details as mentioned in the  Step 1 for the Query Parameter
2.    In the Resources Tab, enter the resource url  and select the Method type , provide an valid name for the method

Here we can observe that Instead of the Value 7 we have provided that field as ##CustomerId##, now click on Next.

3. In the Method Details page, the ##CustomerId## is exposed in the URL Attributes panel, provide the default value of the Customer Id  , Click Next 

4. Now In this case , I have not provided the Response XSD which will be auto generated by the Jdeveloper and the DC palette will look as shown below after completing the wizard

About

Tips and Tricks from Oracle's JDeveloper & ADF QA

Search

Archives
« January 2014 »
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today