Oracle ORDS使用SQL Developer发布Webservice
来源:互联网 发布:windows 2008ntp服务器 编辑:程序博客网 时间:2024/05/29 21:35
Assumptions and Comments
This article assumes the following.
- You already have a functioning installation of ORDS.
- The paths for the ORDS configuration match those from the ORDS installation article listed above.
- You have an Oracle database available. In this article I will be using a 12c database, but it works just the same with an 11g database.
- You have a way to call the web services. Some GET web services can be called from a browser, but the other methods require some coding, or a REST client. I used "curl" and the "Advanced REST client" extension for Chrome.
- You already have an understanding of the various pieces of ORDS functionality. This article will not teach you about this, but the linked articles will.
Enable ORDS for a Schema
Right-click on the connection and select the "REST Services > Enable REST Services..." menu option.
Check the "Enable schema" checkbox and alter the schema alias if you don't want to expose the schema name in the URL. In this case we will ignore authorization. Click the "Next >" button.
If you want to see the code that will run to enable ORDS for the schema, click the "SQL" tab.
Click the "Finish" button.
Click the "OK" button.
Enable AutoREST for an Object
Right-click on the object and select the "Enable REST Service..." menu option.
Check the "Enable object" checkbox and specify an object alias if you don't want to expose the object name in the URL. In this case we will ignore authorization. Click the "Next >" button.
If you want to see the code that will run to enable AutoREST for the object, click the "SQL" tab.
Click the "Finish" button.
Click the "OK" button.
Create Basic RESTful Web Service
To let SQL Developer connect to your ORDS server, you will need to create a user through ORDS with the "SQL Developer" role.
cd /u01/ords$JAVA_HOME/bin/java -jar ords.war user tim_hall "SQL Developer"
The credentials are stored on the ORDS server in the following location.
cat /u01/ords/conf/ords/credentials
With the ORDS user in place, you can now proceed to develop web services using SQL Developer.
Select the "View > REST Data Service > Development" menu option.
On the resulting "REST Development" pane, click the connect button.
If you don't already have a connection, click the "+" button.
Enter the connection details, including the "Username" configured on the ORDS server, then click the "OK" button.
Click the "OK" button.
Enter the ORDS credentials and click the "OK" button.
Right-click on the "Modules" tree node and select the "New Module..." menu option.
Enter the module details and click the "Next >" button.
Enter the template details and click the "Next >" button.
Enter the handler details and click the "Next >" button.
Click the "Finish" button.
Expand the tree and click on the GET handler. Click on the "Worksheet" tab. Enter the query associated with the GET handler.
All changes are performed locally, so changes need to be uploaded to the server to take effect. Right-click on the module and select the "Upload..." menu option.
Click the "OK" button.
The web service should now be available from your ORDS.
http://ol7-121.localdomain:8080/ords/pdb1/testuser2/testmodule1/emp/
If you want to save a local copy of the configuraton, right-click on the tree and select the "Save As..." menu option, then name and save the zip file. At the time of writing, this configuration is only a XML representation of the configuration, not the SQL used to create it.
ORDS Administration
You will need to create an ORDS user with the "Listener Administrator" role to let SQL Developer connect to your ORDS server for administration.
cd /u01/ords$JAVA_HOME/bin/java -jar ords.war user tim_hall "SQL Developer","Listener Administrator"
The credentials are stored on the ORDS server in the following location.
cat/u01/ords/conf/ords/credentials
With the ORDS user in place, you can now administer ORDS using SQL Developer.
Select the "View > REST Data Service > Administration" menu option.
Connect as you did for the developer pane. All configuration changes are local and need to be uploaded to the ORDS server for them to take effect.
SQLcl REST Command
The SQLcl utility includes a REST
command that can be quite useful.
$ ./sql testuser1/testuser1@pdb1SQLcl: Release 4.2.0.16.175.1027 RC on Fri Jul 01 16:13:22 2016Copyright (c) 1982, 2016, Oracle. All rights reserved.Connected to:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit ProductionWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing optionsSQL> rest helpREST------REST allows to export ORDS 3.X services. REST export - All modules REST export- Export a specific module REST export - Export a specific module related to the given prefix REST modules - List the available modules REST privileges - List the existing privileges REST schemas - List the available schemasSQL>
Let's get a list of the REST modules.
SQL> rest modulesNAME PREFIX STATUS ITEMS_PER_PAGE----------- ------------- --------- --------------testmodule1 /testmodule1/ PUBLISHED 0SQL>
Now we know the module name, we can export the definition.
SQL> rest export testmodule1declare l_module_id number; l_template_id number; l_handler_id number; l_parameter_id number;begin l_module_id := ORDS_METADATA.ORDS_SERVICES.create_module( p_name => 'testmodule1' , p_uri_prefix => '/testmodule1/' , p_items_per_page => 0 , p_status => 'PUBLISHED' ); l_template_id := ORDS_METADATA.ORDS_SERVICES.add_template( p_module_id => l_module_id, p_uri_template => 'emp/:empno' , p_priority => 0 , p_etag_type => 'HASH' ); l_handler_id := ORDS_METADATA.ORDS_SERVICES.add_handler( p_template_id => l_template_id, p_source_type => 'json/query' , p_method => 'GET' , p_items_per_page => 0 , p_source => 'SELECT * FROM emp WHERE empno = :empno');commit;end;SQL>
- Oracle ORDS使用SQL Developer发布Webservice
- Oracle REST Data Services (ORDS) 发布 RESTful Web Services 教程
- Oracle Sql Developer 使用技巧
- Oracle SQL Developer 使用记录
- Oracle APEX installation with ORDS
- Oracle发布免费数据库开发工具SQL Developer 1.2
- 关于Oracle sql developer与plsql developer使用
- Oracle PL/SQL Developer使用技巧
- Oracle SQL Developer使用简要说明
- Oracle SQL Developer 使用简要说明
- ubuntu 下配置使用 Oracle SQL Developer
- Oracle SQL Developer 使用简要说明
- 不安装oracle使用PL/SQL Developer
- 使用oracle SQL developer 怎么建立connections
- Oracle SQL Developer Data Modeler使用教程
- Oracle--SQL Developer创建连接及使用
- 使用Sql Developer调试Oracle步骤
- 在Oracle AS 10g 上发布pl/sql webservice.
- 打造简单的BaseActivity
- Java反射探究——从类加载说起
- 如何新建、打开和编辑Python文件?
- 802.11无线网络权威——(二十、使用802.11接入点)
- Surf算法特征点检测与匹配
- Oracle ORDS使用SQL Developer发布Webservice
- Mysql 存储引擎的区别和比较
- mnist的读取和图片转换
- QT学习杂项1
- EMV规范(四)——读应用数据
- 【剑指offer】题44:扑克牌的顺子
- python 把EXCEL读取为dict
- 汉字转拼音,用户表增加拼音字段,并将汉字姓名对应的拼音赋值给拼音字段
- BZOJ 3505 数三角形 (数论 组合数 gcd)