This content has been marked as final. Show 3 replies
Here is a simple example for you (assumes you have the EMP table available in your workspace), that just does a simple INSERT:
1) In the sample oracle.example.hr module,create a new Resource Template with the following:
- URI Template: employee/
[Leave other defaults]
2) In the module, create a Handler with the following:
- Method: POST
- Requires Secure Access: No
[ Leave other defaults]
3) Click Create.
begin insert into emp (ename) values (:ENAME); end;
4) In that Handler, create a parameter with the following:
- Name: ENAME
- Bind Variable Name: ENAME
[Leave other defaults, note Source Type of HTTP Header].
6) You now have the RESTful module setup and ready to consume from within an application. Create a new database application, with defaults.
7) In Shared Components, go to 'Web Service References' and create a new one, with the following:
- Type: REST
- REST Details:
- Name: INSERT EMP
- URL: http://<domain>:<port>/apex/<SQL Workshop Path Prefix, defaults to workspace name>/<Module URI Prefix>/<Handler URI Template>/
Take a look at one of the other handlers in the sample module, run the 'Test' facility in the handler where the output type is set to JSON, and this should give you an idea of what the URL will look like, you'll just have to replace the handler URI Template accordingly.
- HTTP Method: POST
- Basic Auth: No
- REST HTTP Headers: ENAME
- Click Next.
- REST Inputs: Delete blank one and hit Next. There are no input parameters.
- REST Outputs: Delete blank one, select 'Text' for Output Format (which allows you to create the reference).
- Test the call if you like here by hitting Test and following the steps on the testing page.
- Then Create the reference.
8) You now have the reference setup as required by the application and are ready to create a simple form to work on that reference and INSERT a row to EMP. Click the 'Create Form on Web Service' button and define the following attributes:
- Service & Operation: Web Service Reference: 'INSERT EMP', leave other defaults.
- Page and Region Attributes: Leave default.
- Input Items: Leave default of creating a new page item to be used to enter the new ENAME value.
- Output Items: None.
9) Run the page, enter a value for the ENAME, say 'FALDO', then 'Submit'.
10) In SQL Workshop, verify the new row has been added in the EMP table.
Hope that helps.
Edited by: Anthony Rayner on Feb 8, 2013 2:33 PM
Thanks for your quick and detail reply. Post RESTful method works from Apex (just like you described), It works from simple html file with post form as well. The only place were post method does NOT work is RESTful services "Test/Set Bind Variable". Clicking on test produces "We're sorry, our service is temporarily unavailable"
3 follow up question
1) Is above described failure to Test post method a bug or I am doing something wrong?
2) Is there a plan to support post input parameter as an array of values?
3) Is there a plan to enable run in debug mode and have detail error descriptions rather then "We're sorry, our service is temporarily unavailable"
Regarding your questions, my colleague Hilary was very kind in helping to provide some information in order to answer your questions, that I didn't know the answer for...
#1 - This issue is expected behaviour with the current 'Test' and 'Set Bind Variables' test options in RESTful Services, with any non-GET method including POST in APEX 4.2 (which is the current version used by a DB Cloud Service on cloud.oracle.com). Apologies for any confusion this may have caused. In the next release of APEX (4.2.1), we have endeavoured to address any confusion over this behaviour by only making the test buttons available for GET handlers.
#2 - We hope to extend the testing functionality in RESTful Services in a future release of APEX, to support the testing of the other available handler methods. We're not aware of any current plans to support post input parameters as an array of values, but will discuss with the relevant developers for further information.
#3 - In a future release of APEX and APEX Listener, we hope to extend the error logging capabilities of RESTful Services, to assist in the identification and resolution of issues raised during the use of RESTful Services.
Hope that helps and please let us know if you have any more questions or feedback.