Showing posts with label RESTful. Show all posts
Showing posts with label RESTful. Show all posts

Thursday, 24 January 2013

Restful services plsql database


To enable restful services from the database (apex) (not restfull services from regions) you must have configured apex listener 2.0 or the weblogic listener.

Enable RESTful services from database
1. Start sqlplus as sys in root-directory of apex
2. Unlock apex_public_user and give new password
3. execute @apex_rest_config
        Set password for apex_rest_public_user and apex_listener (same as apex_public_user?)
  
4. alter user <schema-workspace> grant connect through apex_rest_public_user


Installation of Apex listener (linux)
1. download listener software
2. unpack zipfile
3. install java (if not available) JRE1.6
4. Go to apex-listener directory (apex.war)
5. Define configuration-directory (one level below current directory)

java - jar apex.war configdir $PWD/config

6. Start listener

java - jar apex.war

The first time all kind of configuration information is asked
a. hostname
b. database sid/service
c. port number database
d. location of static resources (path to the images of apex)
e. port http-server listener has to listen on 


URL exampleservice
    http://<host>:<port javalistener>/apex/<workspace>/hr/empinfo/

De service zal default naar '1-ste'  schema gaan waar workspace aan gekoppeld is. Dit schema moet rechten hebben om om via rest-service nar buiten te gaan.

Als sys-user
alter user <> grant connect through apex_rest_public_user;

Creating RESTful webservice in APEX

It's possible to create a report in Apex that works as a service.

To be able to define a webservice the administrator has to make a change in the default configuration of the apex workspace.

  1. Allow Restfull access
Only than developers are able to define a report as as webservice.  

  1. Create region
  2. Modify attributes 
  • Define a static id for the region
  •  Enable Restful Access, the url will be shown

Ready.    

The url looks like this:


http://<host>/pls/apex/apex_rest.getReport?app=613&page=5&reportid=hekr01&parmvalues=H01&output=xml


app               = Application name/number
page             = Pagenumber
reportid        = Unique identifier report (defined at creation)
output           = Format (XML or JSON)
parmvalues  = additional parameters (value)

The value of <H01> will be assigned to the first itemof region

Use of multiple parameters:
First the values (comma seperated), than the items.

 http://<host>/pls/apex/apex_rest.getReport?app=613&page=5&reportid=hekr01&parmvalues=H01,H02&output=xml

The values are assigned sequentially to the items of the report based on their (internal) ids.
So, H01 will be assigned to the item with the lowest ID and H02 will be assigned to the next item notwithstanding which region.