Web Service torilla tavataan! Jari Putula Avarea Oy COPYRIGHT BY AVAREA 2009 1 Google Trends COPYRIGHT BY AVAREA 2009 2 1
1. Mahdollistajat 2. Web service? 3. KISS 4. Miksi? 5. Analogia 6. Ajax 7. Esimerkki Agenda COPYRIGHT BY AVAREA 2009 3 Mahdollistajat (enablers) Avoin data (http://www.theodi.org/ http://www.suomi.fi/suomifi/tyohuone/yhteiset_palvelut/avoin_data/) Teknologiat Pilvistö (Amazon WS, Microsoft Azure & co) Työkalut (Google & co) Rajapinnat Tapa tehdä Web2.0 (2004->) Some Blogit Ria Käyttäjien osallistuminen (Wikipedia, Flickr, Picasa Instagram jne.) Mashup crowdsourcing COPYRIGHT BY AVAREA 2009 4 2
Web Service Web service (www-sovelluspalvelu) on W3C:n määritelmän mukaan ohjelmistojärjestelmä, joka mahdollistaa keskenään yhteensopivan tietokoneiden välisen vuorovaikutuksen tietoverkon yli. Käytännössä termillä tarkoitetaan World Wide Web -pohjaisia ohjelmointirajapintoja: jokin palvelin tarjoaa muilla tietokoneilla toimiville ohjelmistoille palvelun HTTPn tai muun Internet-pohjaisen protokollan yli. http://fi.wikipedia.org/wiki/web_service COPYRIGHT BY AVAREA 2009 5 SOAP/REST/web services? wiki: SOAP (Simple Object Access Protocol) on tietoliikenneprotokolla jonka pääasiallisena tehtävänä on mahdollistaa proseduurien etäkutsu (RPC). Se on toimintaperiaatteeltaan samantapainen kuin muut RPCprotokollat, kuten CORBA tai RMI, mutta sen erityispiirteinä on pohjautuminen XML-kieleen ja toimiminen useiden eri protokollien yli. Sitä käytetään pääasiassa HTTP-protokollan yli. As described in a dissertation by Roy Fielding, REST is an "architectural style" that basically exploits the existing technology and protocols of the Web, including HTTP (Hypertext Transfer Protocol) and XML. REST is simpler to use than the well-known SOAP (Simple Object Access Protocol) approach, which requires writing or using a provided server program (to serve data) and a client program (to request data). COPYRIGHT BY AVAREA 2009 6 3
KISS Jobs Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. (But it s worth it in the end because once you get there, you can move mountains.) - Steve Jobs COPYRIGHT BY AVAREA 2009 7 KISS gurut KISS-periaate (engl. Keep It Short and Simple tai Keep It Short Stupid tai Keep it simple, Stupid!) on ajatusmalli, joka pyrkii yksinkertaisuuteen. Termin alkuperästä ei ole varmaa tietoa. Jo Albert Einstein muotoili sanonnan "everything should be made as simple as possible, but no simpler" (kts. myös Occamin partaveitsi ja Einsteinin hiomakivi.) COPYRIGHT BY AVAREA 2009 8 4
SOAP vs. REST. KISS? COPYRIGHT BY AVAREA 2009 9 Miksi web service Tarve ladata asynkronisesti tietoa tapahtumankäsittely datan määrä (esim. Google Earth) sovelluslogiikka Halu olla lataamatta koko web sivua (!) uudelleen COPYRIGHT BY AVAREA 2009 10 5
Tori COPYRIGHT BY AVAREA 2009 11 Juhlat COPYRIGHT BY AVAREA 2009 12 6
404 COPYRIGHT BY AVAREA 2009 13 Design arkkitehtuuri Web sovellus Middle tier Backend Web - palvelin (Proxy) DB COPYRIGHT BY AVAREA 2009 14 7
Design The Devil s in the Details XMLHttpRequest Ajax työjuhta Cross site scripting (xss); mistä data haetaan Rajapinnat (esim. facade design pattern) Abstrahoi monimutkainen palvelu yksinkertaiseksi rajapinnaksi Määrittele palvelu yksinkertaisesti getclient&id=1234&history=yes Yhtenäistä parametrien nimet siten että niillä on sama konteksti ja merkitys asiakassovelluksella ja kantaskriptissä COPYRIGHT BY AVAREA 2009 15 Javascript Ajax var root="http://xp92:8080/sasstoredprocess/do?"; function kayttajapainoinappia(){ makerequest(root + getsasohjelma() + "&asiakas=" + getasiakasname());} function makerequest(urli) { if (window.xmlhttprequest) { // Mozilla, Safari,... else if (window.activexobject) { // IE... httprequest.onreadystatechange = function() { nappaavastaus(httprequest); }; httprequest.open('get', urli, true); httprequest.send(null); } function nappaavastaus(httprequest) { if (httprequest.readystate == 4) { if (httprequest.status == 200) { var vastaus=httprequest.responsetext;... COPYRIGHT BY AVAREA 2009 16 8
Backend SAS SP %global asiakas; Data _null_; Set sashelp.class (where=(name= &asiakas )); File _webout; Put name; Run; COPYRIGHT BY AVAREA 2009 17 Design arkkitehtuuri Web sovellus Middle tier Backend Web -palvelin (Proxy) DB var root="http://xp92:8080/sasstoredprocess/do?"; function kayttajapainoinappia(){ makerequest(root + getsasohjelma() + "&asiakas=" + getasiakasname());} function makerequest(urli) { if (window.xmlhttprequest) { // Mozilla, Safari,... else if (window.activexobject) { // IE... httprequest.onreadystatechange = function() { nappaavastaus(httprequest); }; httprequest.open('get', urli, true); httprequest.send(null); } function nappaavastaus(httprequest) { if (httprequest.readystate == 4) { if (httprequest.status == 200) { var vastaus=httprequest.responsetext;... %global asiakas; Data _null_; Set sashelp.class (where=(name= &asiaka s )); File _webout; Put name; Run; COPYRIGHT BY AVAREA 2009 18 9
Kaikki sitä tekevät COPYRIGHT BY AVAREA 2009 19 Kiitos, näkemiin ja kysymyksiä Jari Putula Konsultti Avarea Oy Puustellinpolku 8 00410 Helsinki Finland www.avarea.fi Tel. +358 40 409 2062 Mail jari.putula@avarea.fi COPYRIGHT BY AVAREA 2009 20 10