Top Banner
REX Simple SQL-XML-ReST Mapping Direct Database to Web Service Service Sean J. Vaughan, UW IT
20

Rex: Database Driven Web Services Service

Nov 18, 2014

Download

Documents

vaughan6161

Presentation about the open source REX database driven web services service.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Rex: Database Driven Web Services Service

REXSimple SQL-XML-ReST MappingDirect Database to Web Service Service

Sean J. Vaughan, UW IT

Page 2: Rex: Database Driven Web Services Service

Language Bullies• …are trying to take authority over data!!!

• SQL (Java|Python|Perl|Ruby) XML HTTP

Page 3: Rex: Database Driven Web Services Service

Contract First!• The contract that matters most:

The Web Service• SQL (Java|Python|Perl|Ruby) XML HTTP

– All try to take over the schemas forcing tough choices– Multiplies Impedance Mismatch Challenges– Nope.

Page 4: Rex: Database Driven Web Services Service

SQL as Data DSL

• SQL XML HTTP

Page 5: Rex: Database Driven Web Services Service

E.g. UW Short Url Service (usus)

• Like tinyurl, bit.ly, goog.le, etc.

• For Faculty and Staff to brand shared links.

• (Hypothetical)

Page 6: Rex: Database Driven Web Services Service

Web Form

url:

Page 7: Rex: Database Driven Web Services Service

Do it

1. Create Schemas

2. Write SQLX Queries

3. Register in REX UI

Page 8: Rex: Database Driven Web Services Service

XML Design

• Contract First!

• <UWShortUrl>

<Id>1</Id>

<Url>http://www.washington.edu/</Url>

<UWNetID>vaughan</UWNetID>

</UWShortUrl>

Page 9: Rex: Database Driven Web Services Service

SQL Schema

• CREATE SEQUENCE usus_id_serial;

• CREATE TABLE USUS (

id int default nextval(‘usus_id_serial’),

url text,

uwnetid text

);

Page 10: Rex: Database Driven Web Services Service

SQLX Query

• SELECTXMLElement(name "UWShortUrl",

XMLForest(id AS "Id",url AS "Url",uwnetid AS "UWNetID"

)FROM usus WHERE id=?::integer;

Page 11: Rex: Database Driven Web Services Service

SQL/XML

• Some SQLX functions:– XMLElement

– XMLAgg

– XMLForest

– XMLConcat

• Part of SQL:2008 ISO/IEC standard

• Implemented in Postgresql (partial), MS SQL Server

• MySQL XML sufficient

Page 12: Rex: Database Driven Web Services Service

SQLX Query

CREATE OR REPLACE FUNCTION usus_create (data xml)RETURNS XML AS $$DECLARE

iurl text := (xpath('/UWShortUrl/Url/text()',data))[1];iuwnetid text := (xpath('/UWShortUrl/UWNetID/text()',data))[1];

BEGININSERT INTO usus (uwnetid, url)

VALUES(iuwnetid, iurl);RETURN XMLElement(name "UWShortUrl",

XMLForest(id AS "Id",url AS "Url",uwnetid AS "UWNetID")

) FROM usus WHERE uwnetid=iuwnetid AND url=iurl LIMIT 1;END;$$ LANGUAGE plpgsql;

Page 13: Rex: Database Driven Web Services Service

REX UI: HTTP Endpoint

Page 14: Rex: Database Driven Web Services Service
Page 15: Rex: Database Driven Web Services Service
Page 16: Rex: Database Driven Web Services Service

REX in Production

• UW ITEquipmentDatabase (edb)

Page 17: Rex: Database Driven Web Services Service

REX in Production

• Link Visualization

Page 18: Rex: Database Driven Web Services Service

REX in Production• Network Key Performance Indicators

Page 19: Rex: Database Driven Web Services Service

Extras

• REX Web Services is implemented using REX

• JSON: free

• Supports format in filename suffix:/rex/usus/shorturl/id/1.xml/rex/usus/shorturl/id/1.json

Page 20: Rex: Database Driven Web Services Service

REX on SourceForge

• rex-restsqlxmaphttp://sourceforge.net/projects/rex-restsqlxmap/

– Standalone .war

– Or with self-running Winstone Servlet Container

• Contact us:

[email protected]

[email protected]