Exposing Multiple Methods under One Resource In a Single URL Data Control

Guest Author

Previously, a URL Data Control could be associated with only one HTTP Method. So  if the developer had to expose multiple operations under  a single Resource, he/she had to create one DC for each operation.  Now since Jdeveloper  supports such a functionality from version, multiple operations can be included in a single DC. This blog explains how to include all the operations exposed by a REST Service Resource in a single Data Control. We will use following REST Service to create URL Data Control.

import java.util.ArrayList;
import java.util.Iterator;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
public class EmployeeService {
private ArrayList<Employee> EmpList = new ArrayList<Employee>();
public EmployeeService() {
EmpList.add(new Employee("Adam", 1001, 35, "ADF"));
EmpList.add(new Employee("Bob", 1002, 42, "HR"));
EmpList.add(new Employee("George", 1003, 54, "Apps"));
public ArrayList<Employee> getEmpList() {
return EmpList;
public ArrayList<Employee> addEmployee(Employee emp) {
return EmpList;
public ArrayList<Employee> deleteEmployee(@QueryParam("name")
String name) {
Iterator it = EmpList.iterator();
while (it.hasNext()) {
Employee tmp = (Employee) it.next();
if (tmp.getName().equalsIgnoreCase(name))
return EmpList;
import javax.xml.bind.annotation.XmlRootElement;
public class Employee {
String name;
int id;
int age;
String dept;
public Employee() {
Employee(String name, int id, int age, String dept) {
this.name= name;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setId(int id) {
this.id = id;
public int getId() {
return id;
public void setAge(int age) {
this.age = age;
public int getAge() {
return age;
public void setDept(String dept) {
this.dept = dept;
public String getDept() {
return dept;

Run the REST Service before commencing with Data Control. 

To begin with, create ADF Fusion Application. In Model project invoke create DC Wizard. Name your Data Control RESTDC and click on Next to create URL Connection.

In the next step, give a name to the URL connection, for example URLConn and specify localhost address in the URL Endpoint field.

Also, choose GET as HTTP Method and supply remaining part of REST Service URL in the source field.

In Step 4, choose XML as the data format from the drop down menu. Click Next. XSD will be auto generated by the jdeveloper. In step 5, click on Test URL Connection to check if the connection has been successfully generated.

Click on finish to complete the wizard. The Data Control for GET method in the REST Service has been created successfully and can be viewed under Data Controls Panel.

Now, we will add remaining HTTP Methods in the service to RESTDC. Invoke Create URL DC Wizard in the Model project. Give RESTDC (same name as the previous DC) in the Name field and choose URLConn from the drop- down. Select POST as the HTTP Method and supply the path to POST Operation in source field.

In the next step, specify the XSD which specifies the structure of the request content. Click Next.Choose XML Data format from the drop-down and complete the wizard. You can see another operation added to the same Data Control in the DC Panel.

Similarly invoke Create URL DC Wizard to add DELETE Method to RESTDC.

In step 3, you will be asked to enter a value to test whether URL and source are valid. Enter  "abc" in the values field against param.

Choose XML as Data format and complete the wizard.

Now the Data Controls Panel has all three operations GET, POST and DELETE which are in the resource under a single URL DC.

The names of these methods (loadData, loadData1 etc) can be changed from DataControls.dcx file.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.