rex: database driven web services service

Post on 18-Nov-2014

124 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

DESCRIPTION

Presentation about the open source REX database driven web services service.

TRANSCRIPT

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

Sean J. Vaughan, UW IT

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

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

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.

SQL as Data DSL

• SQL XML HTTP

E.g. UW Short Url Service (usus)

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

• For Faculty and Staff to brand shared links.

• (Hypothetical)

Web Form

url:

Do it

1. Create Schemas

2. Write SQLX Queries

3. Register in REX UI

XML Design

• Contract First!

• <UWShortUrl>

<Id>1</Id>

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

<UWNetID>vaughan</UWNetID>

</UWShortUrl>

SQL Schema

• CREATE SEQUENCE usus_id_serial;

• CREATE TABLE USUS (

id int default nextval(‘usus_id_serial’),

url text,

uwnetid text

);

SQLX Query

• SELECTXMLElement(name "UWShortUrl",

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

)FROM usus WHERE id=?::integer;

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

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;

REX UI: HTTP Endpoint

REX in Production

• UW ITEquipmentDatabase (edb)

REX in Production

• Link Visualization

REX in Production• Network Key Performance Indicators

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

REX on SourceForge

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

– Standalone .war

– Or with self-running Winstone Servlet Container

• Contact us:

– vaughan@uw.edu

– net-tools@uw.edu

top related