Home > Advanced Programming Techni... > Implementing Web Services > Exposing a Report Region as...
Previous |
Next |
RESTful Web services, that are callable with a URL and return either JSON or XML, can be exposed in report regions. In order to expose a report region as a RESTful Web service, the following steps must be performed:
The instance administrator must enable the REST provider feature in instance settings. To enable RESTful access to an Application Express instance, see "Enabling RESTful Access" in the Oracle Application Express Administration Guide.
A developer must enable RESTful access to a report region. See Enabling RESTful Access to a Report Region.
The page that contains the report must not require authentication.
Topics:
To enable RESTful access to a report regions, you must make the page public so no authentication is required and enable the report for RESTful access.
To make a page public:
On the Workspace home page, click the Application Builder.
Select an application.
Select the page that contains the report you want to enable.
The Page Definition appears.
Under Page, click the edit icon.
Under Security, select Page is Public from the Authentication list.
Click Apply Changes.
To enable a report region for RESTful access:
On the Workspace home page, click Application Builder.
Select an application.
Application Builder appears.
Select the page that contains the report you want to enable.
The Page Definition appears.
Under Regions, click the name of the region that contains the report you want to enable.
Under Attributes, enter a value for Static ID field. This value is used to access the report RESTfully.
From the Enable RESTful Access List, select Yes.
Click Apply Changes.
Once you enabled a report for RESTful access, you need to know the endpoint URL and parameters to pass to the RESTful Web service. The endpoint URL is similar to the URL used to access this instance of Application Express followed by the resource apex_rest.getReport. For example:
http://apex.oracle.com/apex/apex_rest.getReport
Tip: If your client uses the POST method, you must also set the HTTP Header,Content-Type , to the value application/x-www-form-urlencoded . |
Name | Default | Required | Description |
---|---|---|---|
app |
N/A |
Yes | The numeric ID or alias of the application that contains the RESTful enabled report. |
page |
N/A |
Yes | The numeric ID or alias of the page that contains the RESTful enabled report. |
reportid |
N/A |
Yes | The Static ID attribute of the RESTful enabled report. |
parmvalues |
null |
No | Values for the report parameters can be sent in a comma separated list. For example: CLERK,10 |
lang |
en |
No | Sets the NLS environment variables prior to running the report based on the language passed in. For example: de |
output |
xml |
Yes | This determines whether XML or JSON will be returned to the client. Domain of possible values are: xml, json |
The apex_rest service also has an operation to allow discoverability of RESTful enabled reports, given an application ID or alias. The response is an XML document with a description of all reports that can be accessed by RESTful Web services. This service is invoked with a URL similar to the following:
http://apex.oracle.com/apex/apex_rest.getServiceDescription?app=691
In the URL above, 691 is the numeric ID of an application. The document returned is similar to the following:
<?xml version="1.0"?> <urn:getServiceDescriptionResponse xmlns:urn="urn:oasis:names:tc:wsrp:v1:types"> <urn:requiresRegistration>false</urn:requiresRegistration> <urn:offeredPortlets> <urn:PortletDescription> <urn:portletHandle>employees</urn:portletHandle> <urn:markupTypes> <urn:mimeType>application/xml</urn:mimeType> <urn:mimeType>application/json</urn:mimeType> </urn:markupTypes> <urn:groupID>1</urn:groupID> <urn:description/> <urn:title>EMP</urn:title> <urn:keywords> <urn:value>P1_JOB</urn:value> <urn:value>P1_DEPTNO</urn:value> </urn:keywords> </urn:PortletDescription> </urn:offeredPortlets> </urn:getServiceDescriptionResponse
The portletHandle
maps to the Static ID of the report region or the reportid
parameter in the REST request. The groupID
maps to the page id or the page parameter in the REST request. Finally, any parameters used by the SQL report are listed as children of the keywords
node.