290 likes | 390 Views
http://turing.cs.pub.ro/webs_07. Aplicatii Web bazate pe semantica, agenti si servicii. Universitatea Politehnica Bucuresti Anul universitar 2007-2008, Master Adina Magda Florea. Servicii Web. Servicii SOA Standarde SOAP WSDL UDDI. Servicii Web.
E N D
http://turing.cs.pub.ro/webs_07 Aplicatii Web bazate pe semantica, agenti si servicii Universitatea Politehnica BucurestiAnul universitar 2007-2008, MasterAdina Magda Florea
Servicii Web • Servicii • SOA • Standarde • SOAP • WSDL • UDDI
Servicii Web • Serviciile Web au aparut ca o tehnologie comuna de integrare • Serviciile Web par a fi baza noii generatii de aplicatii distribuite • Arhitecturile Orientate pe Servicii utilizeaza servicii Web • Orchestrarea serviciilor permite orientarea pe servicii
Service Oriented Architecture • SOA este un pattern arhitectural • mai multi consumatori de servicii • mai multi ofertanti de servicii • potential, mai multe directoare de servicii
Service Oriented Architecture • Servicii autonome (de dorit) • Comunicare bazata pe mesaje • Alinierea cu procesul de business • Serviciile sunt blocurile constructive ale aplicatiilor: • B2B (Business to Business) • A2A (Application to Application)
Servicii Web: arhitectura de baza Service Broker Registry; well-known Publish or announce (WSDL) Find or discover (UDDI) Service Provider Service Requestor Bind or invoke (SOAP) Not well-known
Profil de baza (BP 1.0) • Web Services Interoperability Organization (WS-I) a specificat Basic Profile version 1.0: • SOAP 1.1 • HTTP 1.1 • XML 1.0 • XML Schema Parts 1 and 2 • UDDI Version 2 • WSDL 1.1
Descrierea unui serviciu • Numee.g., GetTemperature • Tipul parametrilor de intraree.g., (String, String) • Tipul parametrilor de iesiree.g., Integer
SOAP (Simple Object Access Protocol) • Folosit pentru schimbul de mesaje HTTP, SMTP si SIP (Session Initiation Protocol for Internet telephony) • Proiectat initial pentru "remote-procedure calls" (RPC) • Bazat pe caractere, deci usor de incriptat/decriptat • Ineficient deoarece este bazat pe caractere (si nu binar) • Nu descrie interactiuni bidirectionale si n-party
Ex. Cerere SOAP POST /temp HTTP/1.1 Host: www.socweather.com Content-Type: text/xml; charset="utf-8" Content-Length: xxx SOAPAction: "http://www.socweather.com/temp" <!– Ce este deasupra sunt HTTP headers --> <?xml version=“1.0”?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <env:Body> <m:GetTempxmlns:m="http://www.socweather.com/temp.xsd"> <m:City>Honolulu</m:City> <m:When>now</m:When> </m:GetTemp> </env:Body> </env:Envelope>
Ex. Raspuns SOAP HTTP/1.1 200 OK Content-Type: text/xml; charset="utf-8" Content-Length: xxx SOAPAction: "http://www.socweather.com/temp" <?xml version=“1.0”?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <env:Body> <m:GetTempResponsexmlns:m="http://www.socweather.com/temp.xsd"> <DegreesCelsius>30</DegreesCelsius> </m:GetTempResponse> </env:Body> </env:Envelope>
WSDL: Web Services Description Language • Descrie o interfata a unui serviciu Web, incluzand: • Definitii ale tipurilor de date • Formatul mesajelor de intrare si iesire • Operatiile oferite de un serviciu • Adrese de retea • Protocol bindings
Ex. WSDL <?xml version="1.0"?> <!– elementul radacina, wsdl:definitions, defineste o multime --> <!– de servicii corelate --> <wsdl:definitions name="Temperature" targetNamespace="http://www.socweather.com/schema" xmlns:ts="http://www.socweather.com/TempSvc.wsdl" xmlns:tsxsd="http://schemas.socweather.com/TempSvc.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
Ex. WSDL <!-- wsdl:types incapsuleaza definitii de schema a tipurilor --> <!-- comunicarii; aici utilizand xsd --> <wsdl:types> <!– toate declaratiile de tip sunt exprimate in xsd --> <xsd:schema targetNamespace="http://namespaces.socweather.com" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <!-- xsd def: GetTemp [City string, When string] --> <xsd:element name="GetTemp"> <xsd:complexType> <xsd:sequence> <xsd:element name="City" type="string"/> <xsd:element name="When" type="string"/> </xsd:sequence> </xsd:complexType> </xsd:element>
Ex. WSDL <!-- xsd def: GetTempResponse [DegreesCelsius integer] --> <xsd:element name="GetTempResponse"> <xsd:complexType> <xsd:all> <xsd:element name="DegreesCelsius" type="integer"/> </xsd:all> </xsd:complexType> </xsd:element> <!-- xsd def: GetTempFault [errorMessage string] --> <xsd:element name="GetTempFault"> <xsd:complexType> <xsd:all> <xsd:element name="errorMessage" type="string"/> </xsd:all> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types>
Ex. WSDL <!– elementele wsdl:message descriu tranzactii potentiale --> <!– Cele mai multe mesaje, asa ca aici, au o singura parte. Mesajele --> <!– cu ma multe parti ofera posibilitatea de a asambla mesaje complexe --> <!-- cererea GetTempRequest este de tipul GetTemp --> <wsdl:message name="GetTempRequest"> <wsdl:part name="body" element="tsxsd:GetTemp"/> </wsdl:message> <!-- raspunsul GetTempResponse este de tipul GetTempResponse --> <wsdl:message name="GetTempResponse"> <wsdl:part name="body" element="tsxsd:GetTempResponse"/> </wsdl:message> <!-- wsdl:portType descrie mesajele dintr-o operatie --> <wsdl:portType name="GetTempPortType"> <!-- wsdl:operation descrie intregul protocol de la intrare --> <!– la iesire sau eroare --> <wsdl:operation name="GetTemp"> <!– Ordinea intrarii si iesirii este importanta; input --> <!– inainte de output indica cerere-raspuns (request-response) --> <wsdl:input message="ts:GetTempRequest"/> <wsdl:output message="ts:GetTempResponse"/> <wsdl:fault message="ts:GetTempFault"/> </wsdl:operation> </wsdl:portType>
Ex. WSDL <!-- wsdl:binding indica un protocol de serializare --> <!– pentru serviciu --> <wsdl:binding name="TempSvcSoapBinding" type="ts:GetTempPortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="GetTemp"> <soap:operation soapAction="http://www.socweather.com/TempSvc"/> <!– specifica faptul ca mesajul din --> <!-- wsdl:operation "GetTemp" foloseste SOAP? @@@ --> <wsdl:input> <soap:body use="literal" namespace="http://schemas.socweather.com/TempSvc.xsd"/> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="http://schemas.socweather.com/TempSvc.xsd"/> </wsdl:output> <wsdl:fault> <soap:body use="literal" namespace="http://schemas.socweather.com/TempSvc.xsd"/> </wsdl:fault> </wsdl:operation> </wsdl:binding>
Ex. WSDL <!-- wsdl:service denumeste un serviciu nou "TemperatureService" --> <wsdl:service name="TemperatureService"> <wsdl:documentation>socweather.com temperature service </wsdl:documentation> <!– conectarea la "TempSvcSoapBinding" --> <wsdl:port name="GetTempPort" binding="ts:TempSvcSoapBinding"> <!– ofera legatura la adresa de retea --> <soap:address location="http://www.socweather.com/TempSvc"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Directorul de servicii • Permite descoperirea serviciilor de catre aplicatii, agenti, ofertanti de servicii Web, clienti de servicii Web, persoane, obiecte, care se pot localiza • White pages – cautare pe baza de nume • Yellow pages – cautare pe baza de caracteristici • Basic directory – poate fi o simpla baza de date (pasiva) sau un broker/facilitator (activ, care alerteaza si recruteaza participanti) • UDDI – atat white pages cat si yellow pages, dar pasive
UDDI: Universal Description, Discovery, and Integration • UDDI este un serviciu Web bazat pe SOAP si XML • UDDI Registry • tModels: descrierea tehnica a comportarii unui serviciu • businessEntities: descrie specificatiile tModels multiple
O cerere catre UDDI Registry Un registru UDDI actioneaza ca un serviciu <?xml version="1.0" encoding="UTF-8"?> <find_business xmlns="urn:uddi-org:api_v3"> <findQualifiers> <findQualifier> uddi:uddi.org:findqualifier:exactmatch </findQualifier> </findQualifiers> <!—gaseste informatii despre companiile cu numele (exactmatch) "WeatherService Inc." --> <name>WeatherService Inc.</name> </find_business>
Raspuns de la UDDI Registry <?xml version="1.0" encoding="UTF-8"?> <businessList> <businessInfos> <businessInfo businessKey="...KO..."> <name>WeatherService, Inc.</name> <serviceInfos> <serviceInfo serviceKey="...KN..." businessKey="...K1..."> <name>Temperature Service</name> </serviceInfo> </serviceInfos> </businessInfo> </businessInfos> </businessList>
Slide-uri bazate pe: • Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley, 2005