oracle rest data services best practices/ overview

42

Upload: kris-rice

Post on 17-Jul-2015

1.463 views

Category:

Software


15 download

TRANSCRIPT

Page 1: Oracle REST Data Services Best Practices/ Overview
Page 2: Oracle REST Data Services Best Practices/ Overview

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

Oracle REST Data Services( Formerly APEX Listener)

Kris RiceSenior Director Database Tools

Best Practices

Page 3: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor

• The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

3

Page 4: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Agenda

• Overview

• New Features in 2.x

• Installation

• Configuration• Multiple Database

• RESTful APIs

• Obligatory Oracle Database Cloud

4

Page 5: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

OverviewOracle REST Data Services

OWA Toolkit support Application Express customization Oracle DB JSON Support Oracle NoSQL Database support Turns Database into an RESTFul API service Allows publishing of URI based access to Oracle

database over REST Results in JSON or CSV Mapping of URI to SQL or PL/SQL All HTML methods GET, PUT, POST, DELETE, PATCH Oauth2 integration Highly scalable

5

Page 6: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

ArchitectureOracle REST Data Services

J2EE Application No Oracle Home required Supported deployments

WebLogic Glassfish Apache Tomcat Standalone – For development

6

Page 7: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

ArchitectureOracle REST Data Services

7

Java Mid Tiers

HTTPS

JDBC

Internet

Firewall

Firewall

OracleNoSQL

Apache httpd

RMI

Separate static content No Mid-Tier state Scales Horizontally Use AJP to talk to backend Allows internal and external access

Page 8: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

2.0 Features

8

Command Line Configuration Multi Database support ICAP Server integration FOP support 2.0.8 adds FOP 1.1 PL/SQL and JavaScript based validation Function Extensibility REST Filtering

Page 9: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

2.0 - Database Users

9

APEX_LISTNER

• Reads REST Definitions

APEX_PUBLIC_USER

• Apex/OWA main connection pool

• Size according to number of concurrent apex users

APEX_REST_PUBLIC_USER

• REST Connection pool for all REST operation

• Size according to concurent REST calls

Page 10: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

2.0 Installation – Step 1

10

Application Express 4.2.2+ required Run apex_rest_config.sql

Page 11: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

2.0 Installation – Step 2

11

Run java –jar ords.war Prompts for:

Location to store configuration Database host/port/sid or service 3 Database Users Path to APEX images

Page 12: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Configuration via SQL Developer

12

File Based for manual setup SQL Developer based

Secured via webserver Retrieve remote config REST based deployment Configuration Validation SQLDev is an Oauth client

Page 13: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Configuration via Command Line

13

Running java -jar ords.war helpconfigdir Set the value of the web.xml config.dir propertyhelp Describe the usage of this program or its commandsmap-url Map a URL pattern to the named database connectionmigrate Migrate a 1.x configuration to 2.x formatsetup Configure database connectionstandalone Launch in standalonestatic Generate a Web Application Archive (WAR)

to serve Oracle Application Express static resourcesuser Create or update credentials for a user for sqldev config

Page 14: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Configuration Files

14

defaults.xmlAll Common settings and defaults for all connection pools

ords/standalone/standalone.properties Standalone settings such as /i/ and port #

conf/apex.xmlConfiguration for APEX/OWA

conf/apex_al.xmlAPEX_LISTENER – reads REST Configuration

conf/apex_rt.xmlAPEX_PUBLIC_PUBLIC_LISTENER – Base connection for REST

credentialsUsers for configuration from SQL Developer

role-mapping.xmlMaps Webserver Roles into RESTful Roles

url-mapping.xmlMultiple database configurations

Page 15: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Connection Pooling

15

Each REST enabled schema grants proxy connect Allows for smaller common pool Connection opens proxied connection All SQL/PLSQL execute at the schema Proxied connection is closed and returned to the pool

Page 16: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

THE number one thing you must do

16

Configure the database connection pool Set the max size Set the initial size Set the timeouts

Page 17: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Multiple Database

17

Routes based on rules to any number of databases Rules are contained in url-mappings.xml 3 Type of Rules: uri-pattern,base-url, and base-path

<pool name="leads_db"

base-url="sales.example.com/apex/leads" />

<pool name="leads_db"

base-path="/sales/leads" />

<pool name="sales_db"

uri-pattern="https://.*\.sales\.example\.com/apex/.*" />

Page 18: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Multi-Database Base-URL Example

18

Assume the listener is deployed at context path: /apex, then:<pool name="leads_db" base-url="sales.example.com/apex/leads" />

<pool name="support_db" base-url="https://support.example.com/apex" />

Match Rule 1http://sales.example.com/apex/leads/f?p=1:1https://sales.example.com/apex/leads/f?p:=1:1

Match Rule 2https://support.example.com/apex/f?p:=1:1http://support.example.com/apex/f?p:=1:1

No Matcheshttp://example.com/apex/f?p:=1:1http://example.com/apex/leads/f?p:=1:1

Page 19: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Multi-Database Base-Path Example

19

Assume the listener is deployed at context path: /apex, then:<pool name="leads_db" base-path="/sales/leads" />

Match Rule 1http://example.com/apex/sales/leads/f?p=1:1

No Matcheshttp://example.com/apex/sales/f?p=1:1http://example.com/apex/f?p=1:1

Page 20: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Multi-Database Pattern Example

20

Assume the listener is deployed at context path: /apex, then:<pool name="sales_db”

uri-pattern="https://.*\.sales\.example\.com/apex/.*"/>

Match Rulehttps://leads.sales.example.com/apex/f?p=1:1 https://deals.sales.example.com/apex/f?p=1:1

No Matcheshttp://hr.example.com/apex/f?p=1:1

Page 21: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Deployment Choices

21

Multiple Mappings

/sales /emp /nhl

/sales /emp /nhl

One ORDS with mappings Single webserver Single management Single upgrade/patch

One ORDS per mapping Multiple webserver Individual control Staggered upgrades

Page 22: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Virus Scanner Integration

22

A lightweight HTTP-like protocol specified in RFC 3507 Scans all file uploads for viruses before it reaches the

database Supported by most commercial Virus scan server Tested with Symantec and McAfee Multiple Open source options such as ClamAV

Page 23: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

ClamAV

23

Install ClamAV http://oracle-base.com/articles/linux/linux-antivirus-clamav.php

Add ICAP support http://c-icap.sourceforge.net/install.html

Page 24: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

JavaScript based Validation

24

Completely eliminates the database Leverages JavaScript knowledge Limit based on HTTP Headers

function isValid()

{

if ( URI.indexOf('hi')>0 ) { return 'false';}

return 'true';

}

Page 25: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

PL/SQL based Validation

25

Use binds in PL/SQL Validation The following are automatically bound if detected

URL PROCNAME P_FLOW_ID P_FLOW_STEP_ID P_INSTANCE P_PAGE_SUBMISSION_ID P_REQUEST

Page 26: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Extensibility

26

Pre and Post Process in PL/SQL<entry key="procedure.postProcess"></entry><entry key="procedure.preProcess"></entry>

Pre and Post Process in JavaFOP2PDFCachingFile Download

Preprocess files in JavaVirus ScannerExcel Upload

Register new Java extentions<entry key="apex.extensions"></entry>

Page 27: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Java Extensibility - Example

27

Called for every request before the database call Requests can be Handled, Modified, or Declined

Page 28: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

REST Filtering

28

Developer now has ability to filter REST requests on the server Operators

$eq,$gt,$lt,$lte,$gte,$ne,$instr Logical

$and, $or Time Based ( coming in 3.0 )

$asof Examples:

{ "qty": { "$gt": 20 } }{"$and": [{"price": {"$ne": 1.99}},{"price": {"$notnull": ""}}] {"price": [{"$ne": 1.99}},{"$notnull": ""}] {"$or": [{"qty": {"$lt": 20}},{"sale": {"$eq": "TRUE"}}] $asof: {"$timestamp": ”……"}

Page 29: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Something went wrong aka Debug Mode

29

Printing Errors to the browser Enable simple debug Full logging of everything via java.util.logging

Full write up on Colm’s Blog http://is.gd/ords_debug

Page 30: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Log Requests to Database

30

Capture all PLSQL calls Capture all Binds

Page 31: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

3.0 New Features

31

Fully committed to REST enablement Simplified installation Auto Table enablement Client REST filtering PL/SQL API for Rest definition Bulk CSV loading over REST Oracle NoSQL Support Database 12.1.0.2 JSON Collections New Plugin framework Jetty for Embedded webserver

Page 32: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

3.0 New Features

32

One line install java -jar build/built/ords.war install Installs new ORDS_METADATA schema Migrates settings from 2.0 to 3.0

Page 33: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Auto REST Enablement

33

Simple menu to enable tables Any combination of operations

Query Insert Update Delete Metadata Bulk Loading

Page 34: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Bulk Loading over REST

34

Factored CSV import from SQL Developer POST the CSV in the body to

/ords/schema-alias/tables/table-alias/batchload Feedback is in the response body Multiple options for the load

Passed via headers

delete=false|true|truncatebatchRows=50|<n>batchesPerCommit=10|<n>errors=50|<n>|UNLIMITEDerrorsMax=<n>responseFormat=RAW|SQLresponseEncoding=UTF8|<encoding-name> responseLocales=null|<locales>dateFormat= <format-string>timestampFormat=<format-string>timestampTZFormat=<format-string>locale=<locale>

Page 35: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Oracle NoSQL

35

Connect to any KVStore NoSQL 3.0 introduces TableAPI Access via full primary key, partial key, or indexes REST is accessible from any language

Page 36: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Standalone - Jetty

36

Eclipse Project http://www.eclipse.org/jetty/

Full webserver Auto creation of Self Signed SSL SPDY Support Apache style access log

Page 37: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

THE number one thing you must do

37

Configure the database connection pool Set the max size Set the initial size Set the timeouts

Page 38: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Oracle Cloud Easy and Graceful Deployment

Deploy AnywhereGracefully move workloads between on-premise and public cloud

Same ArchitectureSame StandardsSame Products

On PremisesTraditional Deployment

or Private Cloud

On CloudAutomated or Fully Managed

Unified ManagementEnterprise Manager manages both On Premise and Cloud*

Page 39: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 39

Oracle Database Cloud – Schema Service Introduction

• Fully Managed Service

• Monthly Subscription by Database Size (5, 20, 50 GB)

• Single Database Schema, Each tenant is a single schema

• Database patches and upgrades performed during scheduled maintenance windows

• Deployed on Engineered Systems

• DB Edition is a modified “limited” (security locked down) EE

• Available since October 2013

Database schema service provides http access, see full instance services to gain full access to a full Oracle Database.

Page 40: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Oracle Database Cloud - Schema ServiceSchema Service Tools

• Drag and drop data movement

• Database Browsing

• Define RESTful Web Services

• Deploy APEX Apps

• SQL worksheet*

• Command Line SQL over https*

SQL DeveloperOracle RESTData Services

Oracle Application Express (APEX)

Java Cloud Service -SaaS Extension

• Allows publishing of URI based access to Oracle database over REST

• Results in JSON or CSV

• Mapping of URI to SQL or PL/SQL

• All HTML methods GET, PUT, POST, DELETE, PATCH

• Oauth2 integration

• Highly scalable

• Java platform specially built to deploy extension for Oracle Software as a Service offerings, including Sales Cloud, Service Cloud, and Marketing Cloud.

• Dedicated environment running WebLogic Server.

• Three pre-configured sizes

• Applications are managed through Oracle Cloud tooling; no customer access to the underlying infrastructure is required.

• Available as an Extra Cost Service.

• Create Tables

• Run any SQL

• Run SQL Scripts

• Browse Database Objects

• Define RESTful Web Services

• Build APEX Apps

• Deploy pre-built productivity apps “Packaged Apps”

• Deploy custom apps

Included with Schema Service

40

Page 41: Oracle REST Data Services Best Practices/ Overview

Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |

Oracle Database as a Service – Rich New ToolsLocal HTML5 Admin App

41

Page 42: Oracle REST Data Services Best Practices/ Overview