Wednesday, October 28, 2015

ADF 12.2.1 ADF BC Support for REST

ADF 12.2.1 provides out of the box support for REST. You should read about all available REST functionality in ADF BC here - 16 Creating RESTful Web Services with Application Modules. I have created very quick sample application to test how it works.

Before generating REST on top of ADF BC, you must configure release version for REST. This can be any number:


To generate REST, go to REST Web Service interface in Application Module and add new REST resource. Here you can select VO and provide REST resource name:


JDeveloper generates REST resource where you could configure attributes to expose, custom methods, etc.:


As soon as you generate REST resource on top of ADF BC, JDeveloper creates new project with web.xml. You could use this project to run/test REST (simply right click and choose Run to test on integrated WLS):


I can test REST through URL: http://127.0.0.1:7101/restapp/rest/1/Employees, ADF returns well structured REST response:


ADF is smart to return only a subset of data, it offers a parameter to control how many rows to fetch in a single call, it also shows if there are more rows to be returned in the result set:


I can set limit parameter to retrieve only one row, this is how it works:


Download implemented sample application - ADFBCRestApp.zip.

12 comments:

  1. Hi Andrejus,

    How can I retrive all rows in a single call with out using limit parameter.

    Regards,
    Vikram

    ReplyDelete
  2. Try to use limit = -1 or set -1 for Range Size in ADF BC REST collection definition.

    Regards,
    Andrejus

    ReplyDelete
  3. Hi Andrejus,

    How can I change the connection to my Database, but instead of using a direct connection (Business Components) using a Weblogic DataSource?

    Thanks
    Daniel

    ReplyDelete
  4. You can type Data Source name into AM config (use Data Source in ADF BC).

    Regards,
    Andrejus

    ReplyDelete
  5. Only that?
    In previous version I had to remove the connection, change bc4j and web.xml files to reference the datasource.

    By any chance do you have any step by step?

    Thanks
    Daniel

    ReplyDelete
  6. Yes, is pretty simple in new versions. You dont need to remove connection or change anything in bc4j or web.xml. I think it is documented in ADF developer guilde.

    Andrejus

    ReplyDelete
  7. Hi Andrejus,

    Is it possible to create Rest webservice on top of ADF BC using programmatic VOs which won't be having any EO?

    Thanks,
    Pallavi

    ReplyDelete
  8. Yes, ADF BC REST is using VO's, it doesnt require EO.

    Andrejus

    ReplyDelete
  9. Hi!
    Great tutorial :)
    But I need help...

    How to add a where clause ?
    For example all rows from database with Sallary = 25000 ?

    Best regards,
    Charles

    ReplyDelete
  10. Hi,

    You can use ADF BC REST query params in REST URL request.

    If you are using bind variables in VO, here is another solution: http://andrejusb.blogspot.lt/2017/01/sql-bind-variable-support-in-adf-bc-rest.html

    Regards,
    Andrejus

    ReplyDelete
  11. is there any example for POST method.
    When i am trying , it's always showing the response code 415 Unsupported Media type.
    I copy the json payload from get result for a record and change the values and used that as the payload in the POST, i also added the content type as json, (also copied from the get result). But still showing the same response.

    Any help on this

    zam

    ReplyDelete
  12. Yes, check this post: http://andrejusb.blogspot.lt/2015/12/crud-with-adf-1221-adf-bc-rest.html

    You need to provide Content-Type, see example.

    Andrejus

    ReplyDelete