Windows Communication Foundation Arhitectura serviciilor web Olteanu by malj

VIEWS: 39 PAGES: 30

									Arhitectura
   serviciilor web

      Olteanu Ana Cristina




                             1
La inceput…




 Interactiunea web traditionala




                                  2
Arhitectura distribuita




                          3
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



                                         4
Avantaje
•   Interoperabilitate
•   Arhitectura distribuita – reutilizabile
•   Distribuire usoara intre consumatori
•   Modularitate



                                              5
Tipuri de arhitecturi

• Arhitectura de tip RPC
• Arhitectura de tip REST
  Client                    Service (pe Server)
              Message




                                                  6
Arhitectura RPC




                  7
Arhitectura de tip RPC
• Remote Procedure Call




                          8
Mod de functionare
• 3 operatii
  – Publicare
  – Descoperire
  – Conectare
• Exemplu : conversie valutara



                                 9
Stiva unui serviciu web




                          10
HTTP
•   HyperText Transport Protocol
•   HTTP 1.1
•   Metode: GET,POST,PUT,DELETE,HEAD,TRACE
•   Arhitecura RPC foloseste doar
       • GET
       • POST


                                             11
SOAP
• Simple Object Access Protocol\
• Diferentiaza major cele doua arhitecturi
• Complex : mesajul incapsulat intr-un
  invelis
• Bazat pe XML


                                         12
Transmitere mesaje XML
folosind SOAP




                         13
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

                                             14
Exemplu de registru UDDI




                           15
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.

                                                     16
Descriere serviciu cu
WSDL(1)
• <definitions name="WeatherService"
  targetNamespace="http://www.ecerami.com/wsdl/WeatherServi
  ce.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"/>
  </message>


                                                          17
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>
                                             <soap:body
                                  encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                                  namespace="urn:examples:weatherservice"
                                             use="encoded"/>
                                  </output>
           </operation>
    </binding>
                                                                                         18
Interactiunea intre acestea




                              19
Arhitectura REST




                   20
Arhitectura REST
• REpresentational State Transfer
• Arhitectura simpla
       – HTTP
       – XML
       – URI

• In REST totul este o resursa


                                    21
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

                                                           22
Concepte REST (2)




                    23
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
                                             24
Exemplu REST




               25
Interfata uniforma
• Concept de baza in REST
  – URI ce respecta reguli : identifica o
    resursa
  – Clientul documentat
  – XML




                                            26
Tehnici de implementare
in .NET
• Windows Communication
  Foundation(WCF)
• Componentele majore:
    - Adresa
    - Binding
    - Contract


                          27
28
Concluzii
• Arhitectura distribuita,scalabilitate
• Cele doua arhitecturi: complex vs
  simplu
• Arhitectura de tip REST necesita mai
  mult efort in partea clientului


                                          29
?

    30

								
To top