Tuesday, December 27, 2016

ADF BC REST 12.2.1.2 Custom Method JDeveloper Workaround

Some of you who would try to implement custom method with ADF BC REST may face JDeveloper 12.2.1.2 wizard issue. JDeveloper 12.2.1.2 wizard is refusing to register ADF BC REST custom method, but it works perfectly on ADF runtime. Seems to be JDeveloper 12.2.1.1 - 12.2.1.2 bug. There is a workaround to modify REST service configuration manually and include custom method binding.

Sample application (available on GitHub - jetcrud). This sample implements custom method in VO implementation class - testCall:


Method is exposed through client interface:


Now if you go to REST service definition and try to enable this method to be included into REST interface - JDeveloper will report error:


Something wrong happens in RSTCustomMethodTab class:


Workaround - add method call into REST service definition manually. I recommend to do it outside of JDeveloper, as it hangs. Change definition in external editor. This is the example for custom method entry:


a

If you take a look into JDeveloper wizard for REST definition, it still shows method unchecked. But you can ignore it:


To execute custom method through REST call, make sure to use POST and specify method name along with parameters in REST request body:


Make sure not to forget to provide action Content-Type:


Check section for more info - 22.13.5 Executing a Custom Action.

11 comments:

  1. thanks very helpful , i was suffering of this for more than 2 week :-)

    ReplyDelete
  2. Very good, now you have solution :)

    Andrejus

    ReplyDelete
  3. Hi Can we implement the same in jdev 11g

    ReplyDelete
  4. No, ADF BC REST is available from 12c only.

    Andrejus

    ReplyDelete
  5. Hi Andrejus,
    Thank you for this post.
    Thought I have a question that is there any way to handle the exceptions in ADF BC REST supported by ADF?
    Because I'm implementing the ADF BC REST service on views with custom methods and I want to handle the exceptions then return the response (with corresponding status) to client.
    Do we have anyway to do that ? I've searched the solution but found nothing.

    Thank you very much.

    ReplyDelete
  6. Probably you need to handle exception in ADF BC REST Java code and return error message text back to the service.

    Regards,
    Andrejus

    ReplyDelete
  7. Hi Andrejus,

    Will above example work on JDEV Studio Edition Version 12.2.1.0.0?
    Because, I'm getting error "JBO-27511: Error occurred due to invalid attribute being passed in input payload. Attribute: "name""
    in postman.

    Regards,
    Subramanian

    ReplyDelete
  8. Yes, will work. Make sure you are passing correct Content-Type mentioned in my post.

    Andrejus

    ReplyDelete
  9. Hi Andrejus,

    Do you know how can we pass input variable which is of type ArrayList object to a custom method exposed as custom method in ADF REST?

    We have a requirement to take multiple Id's in a array/list to java custom method and use them further in logic. Now the question is how can we pass the input in Json while executing REST API POST request? I tried below JSON payload but it is failing.

    {
    "name": "processInvoiceHolds",
    "parameters": [
    {
    "inv_ids":["10010", "10011"],
    "holdStatus": "N"

    }
    ]
    }

    It gave me below error:
    {
    "type": "HTTP://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1",
    "status": 400,
    "title": "Bad Request",
    "detail": "The request content does not represent an action or it has an invalid structure."
    }

    The custom method signature is:
    public String processInvoiceHolds(ArrayList inv_ids, String holdStatus){}

    Please help.

    ReplyDelete
  10. Can we expose methods in ApplicationModuleImpl or is it only valid for ViewObjectImpl

    ReplyDelete