Arhitectura serviciilor web Olteanu Ana Cristina
La inceput… Interactiunea web traditionala
Arhitectura distribuita
Ce este un serviciu web ? Un serviciu web este o aplicatie modulara, auto-descriptiva care poate fi publicata si accesata prin Internet si care foloseste un sistem de mesaje standardizat XML
Avantaje Interoperabilitate Arhitectura distribuita – reutilizabile Distribuire usoara intre consumatori Modularitate
Tipuri de arhitecturi Arhitectura de tip RPC Arhitectura de tip REST Client Service (pe Server)
Arhitectura RPC
Arhitectura de tip RPC Remote Procedure Call
Mod de functionare 3 operatii Exemplu : conversie valutara Publicare Descoperire Conectare Exemplu : conversie valutara
Stiva unui serviciu web
HTTP HyperText Transport Protocol HTTP 1.1 Metode: GET,POST,PUT,DELETE,HEAD,TRACE Arhitecura RPC foloseste doar GET POST
SOAP Simple Object Access Protocol\ Diferentiaza major cele doua arhitecturi Complex : mesajul incapsulat intr-un invelis Bazat pe XML
Transmitere mesaje XML folosind SOAP
UDDI Universal Description, Discovery and Integration http://www.uddi.org Specificatie tehnica pentru a publica si a gasi servicii web in Internet White pages, yellow pages, green pages
Exemplu de registru UDDI
WSDL Web Services Definition Language http://www.w3.org/TR/wsdl/ Limbaj bazat pe XML pentru descrirea interfetei serviciilor web Ce face serviciul ( descriere) Cum se foloseste serviciul (metodele) Unde se gaseste serviciul Nu depinde de protocolul de pe nivelul inferior.
Descriere serviciu cu WSDL(1) <definitions name="WeatherService" targetNamespace="http://www.ecerami.com/wsdl/WeatherService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <message name="getWeatherRequest"> <part name="zipcode" type="xsd:string"/> </message> <message name="getWeatherResponse"> <part name="temperature" type="xsd:int"/>
Descriere serviciu cu WSDL (2) <binding name="Weather_Binding" type="tns:Weather_PortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="getWeather"> <soap:operation soapAction=""/> <input> <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:weatherservice" use="encoded"/> </input> <output> </output> </operation> </binding>
Interactiunea intre acestea
Arhitectura REST
Arhitectura REST REpresentational State Transfer Arhitectura simpla HTTP XML URI In REST totul este o resursa
Concepte REST (1) O pagina web: reprezentare a unei resurse -> de aici si numele URI ( Uniform Resource Identifier) : numele si adresa resursei Anumit format impus de cei ce implementeaza serviciul Exemplu : http://www.example.com/relationships/Alice;Bob http://www.example.com/nextprime/1024 ?1
Concepte REST (2)
Metode HTTP Get (GET),Create (PUT), Update( POST), delete (DELETE) GET /weatherforecast/02110 HTTP/1.1 POST /weatherforecast HTTP/1.1 PUT /weatherforecast/95101 HTTP/1.1 DELETE /weatherforecast/02110 HTTP/1.1 SOAP foloseste doar POST si GET
Exemplu REST
Interfata uniforma Concept de baza in REST URI ce respecta reguli : identifica o resursa Clientul documentat XML
Tehnici de implementare in .NET Windows Communication Foundation(WCF) Componentele majore: - Adresa - Binding - Contract
Concluzii Arhitectura distribuita,scalabilitate Cele doua arhitecturi: complex vs simplu Arhitectura de tip REST necesita mai mult efort in partea clientului
?