Vous êtes sur la page 1sur 31

WebServicesand ServiceOrientedArchitectures(SOA)

GustavoAlonso ComputerScienceDepartment SwissFederalInstituteofTechnology(ETHZ) alonso@inf.ethz.ch http://www.iks.inf.ethz.ch/

Basicinfo

Webpages: http://www.systems.ethz.ch/education/courses/fs10/webservicesandsoa Thisiswhereallthelecturematerialsandadditionalpointerscanbefound Exam:Lastweekofthesemester duringthelecturehours Exercises: Exercisesaremandatoryandarequirementtodotheexam PleaseregisterassoonaspossibleineDoz Course(tentative): Wesservicebasics SOAP WSDL UDDI Composition&BPEL Messaging Web2.0 REST SOAandintegrationarchitectures Presentationsfromindustry
2

Gustavo Alonso, D-INFK. ETH Zrich.

TheWebassoftwarelayer(Ntier)

Browser

Web Server

app server 1

app server 1

MIDDLEWARE

Front end

wrappers Branch 1 Branch 2

Ntierarchitecturesresultfrom connectingseveralthreetiersystems toeachotherand/orbyaddingan additionallayertoallowclientsto accessthesystemthroughaWeb server TheWeblayerwasinitiallyexternalto thesystem(atrueadditionallayer); today,itisslowlybeingincorporated intoapresentationlayerthatresides ontheserverside(partofthe middlewareinfrastructureinathree tiersystem,orpartoftheserver directlyinatwotiersystem) TheadditionoftheWeblayerledto thenotionofapplicationservers, whichwasusedtorefertomiddleware platformssupportingaccessthrough theWeb

user program

user program

Gustavo Alonso, D-INFK. ETH Zrich.

user program

user program

WWWbasics

Theearliestimplementations wereverysimpleandbuilt directlyupontheexistingsystems (client/serverbasedonRPC,TP Monitors,oranyotherformof middlewarewhichallowed interactionthrougha programmableclient) theCGIscript(orprogram) actedasclientinthe traditionalsense(forinstance usingRPC) theuserclickedinagivenURL andtheserverinvokedthe correspondingscript thescriptexecuted,produced theresultsandpassedthem backtotheserver(usuallyas theaddressofawebpage) theserverretrievedthepage andsendittothebrowser

BROWSER URL response page WEB SERVER map URL to CGI script execute CGI script get results back (stdout of CGI script) prepare response page send page to browser Implemented as a normal client CGI script INTERNET

Existing Middleware Infrastructure


4

Gustavo Alonso, D-INFK. ETH Zrich.

Appletsandclients

browser JVM applet


1. Get client 2. Send applet 3. C/S system

Theproblemoftheusingaweb browserasuniversalclientisthatit doesnotdomuchbeyonddisplaying data(itisathinclient): multipleinteractionsareneeded tocompletecomplexoperations thesameoperationsmustbe doneoverandoveragainforall clients theprocessingpowerattheclient isnotused ByaddingaJVM(JavaVirtual Machine)tothebrowser,nowit becomespossibletodynamically downloadtheclientfunctionality(an applet)everytimeitisneeded Theclientbecomestrulyindependent oftheoperatingsystemandisalways underthecontroloftheserver

WEB SERVER
Front end
app server 1

app server 1

wrappers Branch 1 Branch 2

Gustavo Alonso, D-INFK. ETH Zrich.

MIDDLEWARE
5

user program

user program

user program

user program

WebserverasaclientofaEAIsystem

CGIscriptswereinitiallywidelyused astherewasnootherwayof connectingthewebserverwiththeIT systemsothatitcoulddosomething beyondsendingstaticdocuments However,CGIscriptshaveseveral problemsthatarenoteasytosolve: CGIscriptsareseparate processes,requiringadditional contextswitcheswhenacallis made(andtherebyaddingtothe overalldelay) FastCGIallowscallstobemade toasinglerunningprocessbutit stillrequirestwocontext switches CGIisreallyaquickhacknot designedforperformance, security,scalability,etc.

Request 1

Request 2 Web server process Normal CGI calls CGI script child process 2

CGI script child process 1

Request 1

Request 2

Call to underlying middleware Web server process Fast CGI calls

CGI script child process 1


Gustavo Alonso, D-INFK. ETH Zrich.

Call to underlying middleware


6

Servlets

Call servlets Servlet child thread 2 Servlet child thread 1 Call to underlying middleware

Gustavo Alonso, D-INFK. ETH Zrich.

threads

ServletsfulfillthesameroleasCGI scripts:theyprovideawayto invokeaprograminresponseto anhttprequest. However: Servletsrunasthreadsofthe Javaserverprocess(not necessarilythewebserver) notasseparateOSprocesses unlikeCGIscripts,thatcanbe writteninanylanguage, Servletsarealwayswrittenin Java(andare,therefore, portable) canuseallthemechanisms providedbytheJVMfor securitypurposes

Request 1

Request 2 Java server process

ServletsandHTML
HTML request includes < SERVLET NAME=MyServlet> < PARAM NAME=param1 VALUE=val1> < PARAM NAME=param2 VALUE=val2> ... < /SERVLET>

Servlet code import java.servlet.*; public class MyServlet extends GenericServlet { public void service ( ServletRequest request, ServletResponse response ) throws ServletException, IOException { ... } ... }
Gustavo Alonso, D-INFK. ETH Zrich.

HTML document

Justonemorelayer...
BROWSER Internet SALES POINT CLIENT IF no_customer_# THEN New_customer ELSE Lookup_customer Check_inventory IF enough_supplies THEN Place_order ELSE ... Server 1 New_customer Lookup_customer Delete_customer Update_customer Server 2 New_product Lookup_product Delete_product Update_product Server 3 Place_order Cancel_order Update_inventory Check_inventory RPC based system

DBMS DBMS DBMS

Customer database

WEB SERVER

INVENTORY CONTROL CGI script call CLIENT Lookup_product Check_inventory IF supplies_low THEN CGI script call Place_order Update_inventory ...
Gustavo Alonso, D-INFK. ETH Zrich.

Products database

Inventory and order database


9

ontopofexistingsystems
TP Client
Yearly balance ?

TP Client
Monthly average revenue ?

WEB SERVER

Internet

CGI script calls

browser

Front end

TP-Monitor environment

Control (load balancing, cc and rec., replication, distribution, scheduling, priorities, monitoring ) recoverable queue app server 3

app server 1

app server 1

app server 2

user program

user program

user program

user program

wrappers Branch 1 Branch 2 Finance Dept.

Gustavo Alonso, D-INFK. ETH Zrich.

10

BusinesstoBusiness(B2B)
FIREWALL WEB SERVER
Front end

INTERNET

FIREWALL WEB SERVER


Front end

MIDDLEWARE

Service A

wrappers Resource X Resource Y Resource 1 Resource 2

wrappers

Gustavo Alonso, D-INFK. ETH Zrich.

MIDDLEWARE
11

Service B

Service 1

user program

user program

Service 2

user program

user program

user program

user program

user program

user program

LimitationsoftheWWW

HTTPwasoriginallydesignedasa documentexchangeprotocol (requestadocument,getthe document,displaythedocument). Itlackedsupportforclientside parameters Itsarchitecturewasoriginally designedwithhumanusersin mind.Thedocumentformat (HTML)wasdesignedtocope withGUIproblemsnotwith semantics.InEAI,thegoalis almostalwaystoremovehumans fromthebusinessprocesses (mostlytoreducecostsandto speedtheprocessup).Strict formattingrulesandtaggingare keytoexchangingmessages acrossheterogeneoussystems

Interactionthroughdocument exchangecanbeveryinefficient whenthetwosidesofthe interactionareprograms (documentsmustbecreated,sent, parsedonarrival,information extracted,etc.).Unfortunately, httpdoesnotdirectlysupportany otherformofinteraction TheinitialWWWmodelwas heavilybiasedtowardstheserver side:theclient(thebrowser)does notdomuchbeyonddisplaying thedocument.Forcomplex applicationsthatmeant muchmoretrafficbetween clientandserver highloadsattheserverasthe numberofusersincreases

Gustavo Alonso, D-INFK. ETH Zrich.

12

HTTPasacommunicationprotocol

HTTPwasdesignedforexchanging documents.Itisalmostlikeemail(in fact,itusesRFC822compliantmail headersandMIMEtypes): Exampleofasimplifiedrequest(from browser):


GET /docu2.html HTTP/1.0 Accept: www/source Accept: text/html Accept: image/gif User-Agent: Lynx/2.2 libwww/2.14 From: montulli@www.cc.ukans.edu * a blank line *

File being requested (docu2.html) and version of the protocol used

List of MIME types accepted by the browser

IftheGET looksfamiliar,itisnota coincidence.Thedocumenttransfer protocolusedisverysimilartoftp

Information about the environment where the browser is running E-mail or identifier of the user (provided by the browser) End of request

Gustavo Alonso, D-INFK. ETH Zrich.

13

HTTPserverside

Exampleofaresponsefromthe server(totherequestbythe browser):


HTTP/1.0 200 OK Date: Wednesday, 02-Feb-94 23:04:12 GMT Server: NCSA/1.1 MIME-version: 1.0 Last-modified: Monday, 15-Nov-93 23:33:16 GMT Content-type: text/html Content-length: 2345 * a blank line * <HTML><HEAD><TITLE> . . . </TITLE> . . .etc.

Protocol version, code indicating request status (200=ok)

Date, server identification (type) and format used in the request

MIME type of the document being sent

Serverisexpectedtoconvertthedata intoaMIMEtypespecifiedinthe request(Accept: headers)

Header for the document (document length in bytes)

Document sent

Gustavo Alonso, D-INFK. ETH Zrich.

14

Parameterpassing

Theintroductionofformsforallowingusers toprovideinformationtoawebserver requiredtomodifyHTML(andHTTP)butit providedamoreadvancedinterfacethan justretrievingfiles:


POST /cgi-bin/post-query HTTP/1.0 Accept: www/source Accept: text/html Accept: video/mpeg Accept: image/jpeg ... Accept: application/postscript User-Agent: Lynx/2.2 libwww/2.14 From: grobe@www.cc.ukans.edu Content-type: application/x-www-form-urlencoded Content-length: 150 * a blank line * &name = Gustavo &email= alonso@inf.ethz.ch

POST request indicating the CGI script to execute (post-query) GET can be used but requires the parameters to be sent as part of the URL: /cgi-bin/post-query?name=&email=...

As before

...

Data provided through the form and sent back to the server

Gustavo Alonso, D-INFK. ETH Zrich.

15

ChallengesofB2B

ThebasicideabehindB2Bis simpleandfollowsthe client/servermodel.Aservice providedbyonecompanycanbe directlyinvokedbyaclient runninginanothercompany.That way,theinteractionsbetweenthe companiesareautomatedand theirITsystemscandirectly interactwitheachother,thereby speedingupaltransactions betweenbothcompanies. TherearemanyexamplesofB2B interactions.Themostbasiconeis apurchaseorder wherebya companydirectlyplacesanorder withanothercompany.Ifdone correctly,eventhisbasic interactioncanbecomeavery powerfuladvantagefora company.

Theproblemishowtoimplement suchasystem: theclientisnolongernearthe server jointdevelopmentofclient andservermakesnosense theserverandclientarelikely tobehiddenbehindfirewalls theinteractiontakesplace amongexistingsystems,itis notpossibletohomogenize thesupportingplatforms theInternetischeapbutopen toeverybody(unlikeleased linesthatareexpensivebut private) Existingsystems/protocolsare notreallydesignedforsuchtype ofinteractions

Gustavo Alonso, D-INFK. ETH Zrich.

16

Contentsandpresentation

HTMLisataglanguagedesignedto describehowadocumentshouldbe displayed(thevisualformatofthe document). HTMLisoneofthemanytag languagesthatexist,someofthem havingbeinginusebeforeHTMLeven existed Taglanguageshavebeendeveloped andareusedinmanyindustries (aircraftmanufacturing, semiconductors,computermanuals). Taglanguagesprovideastandardized grammardefiningthemeaningoftags andtheiruse TaglanguagesuseSGML,an internationaltextprocessingstandard fromthe80s,todefinetagsetsand grammars

HTMLisbasedonSGML,thatis,the tagsandthegrammarusedinHTML documentshavebeendefinedusing SGML.

Gustavo Alonso, D-INFK. ETH Zrich.

<h2>Table of contents</h2><a name=TOC></a> <ul> <li><a href="SG.htm">1 A Gentle Introduction to SGML</a></li> <li><a href="SG11.htm">2 What's Special about SGML? </a></li> <ul> <li><a href="SG11.htm#SG111">2.1 Descriptive Markup</a></li> <li><a href="SG11.htm#SG112">2.2 Types of Document</a></li> <li><a href="SG11.htm#SG113">2.3 Data Independence </a></li> </ul> <li><a href="SG12.htm">3 Textual Structure</a></li> <li><a href="SG13.htm">4 SGML Structures</a></li> <ul> <li><a href="SG13.htm#SG131">4.1 Elements</a></li> <li><a href="SG13.htm#SG132">4.2 Content Models: An Example</a></li> </ul>

17

HTMLandXML

HTMLonlyprovidesprimitivesfor formattingadocumentwithahuman userinmind UsingHTMLthereisnowayto indicatewhatarethecontentsofa document(itssemantics) Forinstance,aquerytoAmazon.com returnsabookanditspriceasan HTMLdocument ahumanhasnoproblem interpretingthisinformationonce thebrowserdisplaysit toparsethedocumentto automaticallyidentifythepriceof thebookismuchmore complicatedandanadhoc procedure(differentforevery bookstore)

B2Bapplicationsrequiredocuments thataremuchmorestructuredsothat theycanbeeasilyparsedandthe informationtheycontainextracted Tocopewiththisrequirement,the XMLstandardwasproposed ImportantaspectsofXML: XMLisnotanextensiontoHTML XMLisaversionofSGMLthatcan beimplementedinaWeb browser XMLisnotalanguagebuta metalanguage usedtodefine markuplanguages XMLtagshavenostandard meaningthatcanbeinterpreted bythebrowser.Themeaning mustbesuppliedasanadditionin theformofastylesheetor program

Gustavo Alonso, D-INFK. ETH Zrich.

18

DatastructuresinXML
Mouse Bovine Gibbon Orang Gorilla Human Chimp
('Mouse':0.792449, (((('Human':0.105614, 'Chimp':0.171597 ):0.074558, 'Gorilla':0.152701 ):0.048980, 'Orang':0.303652 ):0.121196, 'Gibbon':0.336296 ):0.485445, 'Bovine':0.902183 ):0.0;
<?xml version="1.0" ?> <!DOCTYPE trees SYSTEM "treefile.dtd"> <trees> <tree> <branch> <node> <specie> 'Mouse' </specie> </node> <length> 0.792449 </length> </branch> <branch> <node> <branch> <node> <branch> <node> <branch> <node> <branch> <node> <specie> 'Human' </specie> </node> ... </tree> </trees>

Data Data to to send send

<!ELEMENT trees (tree+)> <!ELEMENT tree (branch,branch,branch?,length?)> <!ELEMENT branch (node,length?)> <!ELEMENT node ((branch,branch)|specie)> <!ELEMENT length (#PCDATA)> <!ELEMENT specie (#PCDATA)> DTD DTD File File
Gustavo Alonso, D-INFK. ETH Zrich.

XML XML File File

19

DTDsanddocuments

ThegoalofXMListoprovidea standardizedwaytospecifydata structuressothatwhendatais exchanged,itispossibleto understandwhathasbeensent TheDocumentTypeDefinition(DTD) specifieshowthedatastructureis described:processinginstructions, declarations,comments,andelements UsingtheDTD,theXMLdocumentcan becorrectlyinterpretedbyaprogram bysimplyparsingthedocumentusing thegrammarprovidedbytheDTD TheideaissimilartoIDLexceptthat insteadofdefiningparametersas combinationsofstandardtypes,a DTDdescribesarbitrarydocumentsas semistructureddata

UsingXMLispossibletoexchange datathroughHTTPandWebservers andprocessthedataautomatically NotethattheuseofXMLreducesthe universalityofthebrowsersincenow abrowserneedsadditionalprograms todealwithspecificmarkup languagesdevelopedusingXML (somewhatsimilartopluginsbut moreencompassingintermsof functionality) However,thisisnotmuchofa problemsincethebrowserisfor humanswhileXMLisforautomated processing XMLcanbeusedastheintermediate languageformarshalling/serializing argumentswheninvokingservices acrosstheInternet

Gustavo Alonso, D-INFK. ETH Zrich.

20

Webservices
CLIENT call stubs, runtime service location SOAP system
Serialized XML doc Wrap doc in HTTP POST request

HTTP support (web client)

This could be RPC, CORBA, DCOM, using SOAP as protocol

SERVER service

stubs, runtime adapters

SOAP system
Serialized XML doc

Retrieve doc from HTTP response

HTTP support (web server)


21

Gustavo Alonso, D-INFK. ETH Zrich.

INTERNET

WebServicesArchitecture

1. 2.

3.

ApopularinterpretationofWeb servicesisbasedonIBMsWeb servicearchitecture basedonthree elements: Servicerequester:Thepotential userofaservice(theclient) Serviceprovider:Theentitythat implementstheserviceandoffers tocarryitoutonbehalfofthe requester(theserver) Serviceregistry:Aplacewhere availableservicesarelistedand thatallowsproviderstoadvertise theirservicesandrequestersto lookupandqueryforservices

Gustavo Alonso, D-INFK. ETH Zrich.

22

MainWebServicesStandards

TheWebservicearchitecture proposedbyIBMisbasedontwo keyconcepts: architectureofexisting synchronousmiddleware platforms currentspecificationsof SOAP,UDDIandWSDL Thearchitecturehasaremarkable client/serverflavor Itreflectsonlywhatcanbedone with SOAP(SimpleObjectAccess Protocol) UDDI(UniversalDescription andDiscoveryProtocol) WSDL(WebServices DescriptionLanguage)

UDDI

SOAP

WSDL
Gustavo Alonso, D-INFK. ETH Zrich. 23

TheServiceBus

TheservicebuscanbeseenasarefactoringofthebasicWebservice architecture,whereahigherdegreeofloosecouplinghasbeen added.

Service Bus

Gustavo Alonso, D-INFK. ETH Zrich.

24

BenefitsofWebservices

Oneimportantdifferencewithconventionalmiddlewareis relatedtothestandardizationeffortsattheW3Cthatshould guarantee: Platformindependence (Hardware,OperatingSystem) Reuseofexistingnetworkinginfrastructure (HTTPhasbecomeubiquitous) Programminglanguageneutrality (.NETtalkswithJava,andviceversa) PortabilityacrossMiddlewaretoolsofdifferentVendors Webservicesarelooselycoupled componentsthatfoster softwarereuse WStechnologiesshouldbecomposable sothattheycanbe adoptedincrementally

Gustavo Alonso, D-INFK. ETH Zrich.

25

WSStandardsandSpecifications
Transport Messaging Description Discovery Choreography Business Processes Stateful Resources Transactions Reliable Messaging Security Event Notification Management Data Access
GustavoAlonso,DINFK.ETHZrich.

HTTP, IIOP, SMTP, JMS XML, SOAP WS-Addressing XML Schema, WSDL WS-Policy, SSDL WS-MetadataExchange UDDI WSCL WSCI WS-Coordination BPML WSCDL WS-BPEL WS-Resource Framework WS-CAF WS-Reliability WS-Security SAML, XACML WS-Notification WSDM OGSA-DAI WS-Transactions WS-Business Activities WS-ReliableMessaging WS-Trust, WS-Privacy WS-SecureConversation WS-Eventing WS-Management SDO
26

WhatisSOA

SOA=ServicesOrientedArchitecture Services =anothernameforlargescalecomponents wrappedbehindastandardinterface(Webservices althoughnotonly) Architecture =SOAisintendedasawaytobuild applicationsandfollowsonpreviousideassuchas softwarebus,ITbackbone,orenterprisebus Thepartthatitisnotinthename Looselycoupled =theservicesareindependentofeach other,heterogeneous,distributed Messagebased =interactionisthroughmessageexchanges ratherthanthroughdirectcalls(unlikeWebservices, CORBA,RPC,etc.)

Gustavo Alonso, D-INFK. ETH Zrich.

27

ThenoveltybehindSOA

TheconceptofSOAisnotnew: Messageorientedmiddleware Messagebrokers Eventbasedarchitectures Thecurrentcontextisdifferent Emergenceofstandardinterfaces(Webservices) Emphasisonsimplifyingdevelopment(automatic) Useofcomplexunderlyinginfrastructure(containers, middlewarestacks,etc.) InterestinSOAarisesfromanumberofreasons: Basictechnologyinplace Moreclearunderstandingofdistributedapplications Thekeyproblemisintegrationnotprogramming

Gustavo Alonso, D-INFK. ETH Zrich.

28

TheneedforSOA

Mostcompaniestodayhavealarge,heterogeneousITinfrastructurethat: Keepschanging Needstoevolvetoadoptnewtechnology Needstobeconnectedofthatofcommercialpartners Needstosupportanincreasingamountofpurposesandgoals ThiswasthefieldofEnterpriseApplicationIntegrationusingsystemslikeCORBAor DCOM.However,solutionsuntilnowsufferedfrom: Tightlyintegratedsystems Vendorlockin(e.g.,vendorstacks) Technologylockin(e.g.,CORBA) Lackofflexibilityandlimitationswhennewtechnologyarises(e.g.,Internet) SOAisanattempttobuildonstandards(webservices)toreduce thecostof integration Itintroducesveryinterestingpossibilities: Developmentbycomposition Largescalereuse Freesdevelopersfromlockin effectsofvariouskinds

Gustavo Alonso, D-INFK. ETH Zrich.

29

SOAvs.Webservices

Webservicesareabout Interoperability Standardization Integrationacrossheterogeneous,distributedsystems ServiceOrientedArchitecturesareabout: Largescalesoftwaredesign SoftwareEngineering Architectureofdistributedsystems SOAispossiblebutmoredifficultwithoutWebservices SOAintroducessomeradicalchangestosoftware: Languageindependence(whatmattersistheinterface) Eventbasedinteraction(nolongersynchronousmodels) Messagebasedexchanges(noRPC) Compositionandorchestration

Gustavo Alonso, D-INFK. ETH Zrich.

30

SOAandwebservices
Thereisnoprobleminsystem design thatcannotbesolved byaddingalevelofindirection. Thereisnoperformance problemthatcannotbesolved byremovingalevelof indirection.

Takeadvantageof Middlewarebutletthe systemdecidewhat touse


GustavoAlonso,DINFK.ETHZrich.

WSInvocationFramework UseWSDLtodescribeaservice UseWSIFtoletthesystemdecide whattodowhentheserviceis invoked: IfthecallistoalocalEJBthen donothing IfthecallistoaremoteEJB thenuseRMI Ifthecallistoaqueuethen useJMS IfthecallistoaremoteWeb servicethenuseSOAPand XML Thereisasingleinterface description,thesystemdecides onthebinding Thistypeoffunctionalityisatthe coreofthenotionofService OrientedArchitecture
31

Vous aimerez peut-être aussi