Pints with Oracle User Group (POUG) and Oracle REST Data Services
An overview of Oracle REST Data Services with all of the examples being BEER themed, thanks to our Polish friends and their awesome event and user group.
• Pints with Oracle User Group • Combines two of my favorite things, ORDS & Beer (beeords!) • Please drink responsibly • I have non-alcoholic slides/content on my blog About these slides… Jeff annoys people on twitter @thatjeffsmith
with Oracle Database since 1999 • Helping build database tools since 2001 • I ‘manage’ these products: whoami Jeff annoys people on twitter @thatjeffsmith
GET, PUT, POST, DELETE • Stateless, so be sure to use LINKs to guide your users POST beers/ => Adds beer, responds w/link GET beers/:id => Jeff annoys people on twitter @thatjeffsmith RESTful Architecture 🍻
HTTP/1.1 200 OK { “id": 100, “name": “Bud Lite“, “score": “0", “comments": “yuck” } {json} URI SQL & PLSQL Marshalls to Database HTTP Request HTTP Response Transforms to JSON SQL Result Set / Standard OUT Oracle REST Data Services ORDS: HTTP to SQL and back Jeff annoys people on twitter @thatjeffsmith
is your webserver & web listener for your Oracle Databases ORDS Static Files -HTML , CSS, JS /db1/hr/emp/ JSON Binary HTML … HTTP(s) Response JDBC pool1 pool2 pool3 Request JDBC JDBC Jeff annoys people on twitter @thatjeffsmith ORDS Architecture Option #2 : Standalone
version of HTTP (recommended!) • Server:8080 – network location where ORDS is running • ords – ords.war, Java servlet • hr – schema alias, where service is defined • examples – module, a collection of services • beers/:id – template, defines the resource Unwinding an ORDS Request Jeff annoys people on twitter @thatjeffsmith PUT https://server:8080/ords/hr/examples/beers/:id
comments FROM untappd WHERE photo_url IS NOT NULL ORDER BY checkin_id DESC Jeff annoys people on twitter @thatjeffsmith GET all beers, with links to pictures
RESTful Services • REST Enable Objects • Manage ORDS Roles and Privileges, OAuth2 Clients • Free! Any major browser. Browser Jeff annoys people on twitter @thatjeffsmith
Metadata (DESC) • Auto REST View – Read interface (GET), Write (PUT+POST+DELETE w/PK on VIEW) • Auto PL/SQL (RPC) – POST to execute stored PL/SQL – We accept {json} in, map to input params, grab output and {json} out Automatic – ORDS owns the code Jeff annoys people on twitter @thatjeffsmith
– Single record only/no paging • Media – Streams the output directly • PL/SQL – Print HTML (HTP.P) or Code the Response yourself (headers and body) Source Types - Shapes Responses Jeff annoys people on twitter @thatjeffsmith
Webservice… • …that INSERTs a record Implementation • Template => media/ • Handler => POST • Source => PL/SQL Jeff annoys people on twitter @thatjeffsmith
:body • We got the other columns from HTTP request headers • We INSERT the record • We set HTTP LOCATION and STATUS …in ~3 lines of PL/SQL!!! What just happened? Jeff annoys people on twitter @thatjeffsmith
Webservice… • …that gives list of links Implementation • Template => beers/:style/pics • Handler => GET • Source => SQL Jeff annoys people on twitter @thatjeffsmith