RESTful Web services, that are callable with a URL and return either JSON or XML, can be exposed in report regions. 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.
- A developer must enable RESTful access to a report region.
- The page that contains the report must not require authentication.
Enabling RESTful Access to a Report Region
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 Express.
- 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.
- 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.
Accessing a RESTful Enabled Report Region from a Web Service Client
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 Oracle 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 valueapplication/x-www-form-urlencoded
.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: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
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
TheportletHandle
maps to the Static ID of the report region or thereportid
parameter in the REST request. ThegroupID
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 thekeywords
node.
No comments:
Post a Comment