Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720...
Transcript of Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720...
CS4720
Thetraditionalsoftwaremodel• Organizationsbuilditallfromscratch
– “Wecan'ttrustanyone!Ourcompetitorswillsabotageus!”
– “Wemustowneverything!Hardwareandsoftware!”
• CompaniesthatbuildsoftwareneedcomponentsthatdoXorY…– …sotheybuyCOTScomponents– Servicecontracts,newreleases,regressiontesting…
2
CS4720
Thetraditionalsoftwaremodel• Howwelldoesthiswork?• SomeprojectdatafromtheDOD:
– 47%ofsoftwaredeliveredcouldnotbeused• Usuallydidn'tmeetrequirements
– 29%offundedsoftwareneverdelivered• Usuallycanceledduetocost/scheduleoverruns
– 19%ofsoftwareusefulafterextensiverework• Costs36timesmoretofixproblemsafterrelease
3
CS4720
Apushtodistribution• “We'rereallygoodat__________,howcanwegetour__________outforpeopletouse?”
• Theideaofdistributedcomputing– “We'regoodatX,butnotsogoodaY…”– “WhatifwegotsomeonetohelpuswithY…butinawaythatwedidn’thavetoincludeanyfancylibraries…
– …andwecouldusetheminwebapps!Andmobiledevices!Andevendesktopapps!”
4
CS4720
AWebService• FromW3C:“asoftwaresystemdesignedtosupportinteroperablemachine-to-machineinteractionoveranetwork.Ithasaninterfacedescribedinamachine-processableformat(specificallyWSDL).OthersystemsinteractwiththeWebserviceinamannerprescribedbyitsdescriptionusingSOAP-messages,typicallyconveyedusingHTTPwithanXMLserializationinconjunctionwithotherWeb-relatedstandards”
5
CS4720
AWebService?• Huh?• Abitmoresimply:Aprogram,accessibleviatheInternet,thatcandosomefunction(eitherforfreeorafee)andcanbedynamicallydiscoveredandused.
• So…Iusewebappsallthetime…arethosewebservices?
6
CS4720
WebServiceasRPC• Theearliestformofatrue“webservices” wasanRPC– remoteprocedurecall.
• Exactlywhatitsoundslike– thereisanexposedfunction/methodthatisaccessedviathewebwhereyoupasstheparametersandthemethodnameandyougetbackareturnvalue.
• NoticehowthisisverydifferentfromtheRESTfulmodel(verbsvs.nouns)
7
CS4720
WebServiceasSOA• RPCwasokay…butitturnedouttobeabitmorelanguagespecificthanwe'dlike
• Whatifwejustastructuredmessage(likeanXMLdocument)thatdescribedwhatwewanted,asopposedtoknowingtheexactfunctioncall?
• ThisisthebasisoftheService-OrientedArchitecture
8
CS4720
WordByWord• Whatisaservice?• "Aserviceisadiscoverableresourcethatexecutesarepeatabletask,andisdescribedbyanexternalizedservicespecification.”
• Businessalignment– businessrequirements• Specifications– self-contained,wellspecified• Reusability– generalenoughtobereused• Agreements– basedonfunction,notplatform• Hostinganddiscoverability– available• Aggregation– canbecombinedtomakebiggerservices
9
CS4720
WordByWord• Whatisanarchitecture?• "Aformaldescriptionofasystem,oradetailedplanofthesystematcomponentleveltoguideitsimplementation.”
• “Thestructureofcomponents,theirinterrelationships,andtheprinciplesandguidelinesgoverningtheirdesignandevolutionovertime."
10
CS4720
Architecture
11
• Architectureis:– Ahigh-enoughlevelofabstractionthatthesystemcanbeviewedasawholeandyetstillprovidesenoughinformationtomakedecisions.
– Supportsthefunctionalityofthesystem.– Allimplementationdetailsarehidden.
• Serviceorientationisawayofintegratingabusinessasasetoflinkedservices.
CS4720
Whatareweactuallytryingtodo?
12
Receive PO
Get Items from InventoryUpdate Customer Profile
Compute Subtotal
Compute Shipping Cost
Compute Export Tax
Compute International Shipping
Compute Total
[ship within US] [ship outside US]
Ship Order
Fork
Join
Branch
Merge
CS4720
SOA– TheQuickVersion• Rightnow,youprobablythinkofasoftwaresystemasbeingacollectionofclasses/objects
• Butusersdon'tthinkofsystemslikethat…theythinkofsystemsassetsoffunctionalitythathelpthemdosomething
• So…whydoweuseobjects?– Easiertomodel– Easiertoprogram– Easiertoexplaintootherprogrammers
13
CS4720
Orisitactuallyeasier?• Turnourideaofasystem90degrees• Functionalityobjects(proceduralabstraction)isthekeyidea,notworldobjects(dataabstraction)
• ThisisthekeyinSOA– AnSOAsystemhasthefunctionalitiesasthemainplayers,nottheobjectsthemselves
– Butmoreso,theseservicesareprovidedbymanydifferentplayers
14
CS4720
Butwhatlanguagedowespeak?• OneearlywaytodowebserviceswaswithSOAP
• SOAP- SimpleObjectAccessProtocol– Acommunicationprotocol– Aformatforsendingmessages– XMLbased
• NotreallymuchmorethananHTTPrequestthatfollowsXML/SOAPstandards
15
CS4720
SOAPRequestPOST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"><m:GetStockPrice>
<m:StockName>IBM</m:StockName></m:GetStockPrice>
</soap:Body>
</soap:Envelope>
18
CS4720
SOAPResponse• HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"><m:GetStockPriceResponse>
<m:Price>34.5</m:Price></m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
19
CS4720
PartsofSOAP• TheEnvelope– requiredrootelementdefiningthedocumentasbeingaSOAPrequest
• TheHeader– notrequired,butcontainsauthenticationand/orpaymentinfofortherequest
• TheBody– theactualmessagebeingsent
20
CS4720
UsingaWebService• Ifyoutookthetimetocreateaservice,thenyouprobablywantpeopletouseit
• Inordertouseaservice,usersneedtoknowwhatinformationtheycansendtheserviceandwhatinformationisgoingtobesentback
• Whatwouldbeevenbetterisifthesoftwarecoulddoallthisautomatically…
21
CS4720
EnterWSDL• WSDL:WebServicesDescriptionLanguage
– AnXMLdocumentusedtogivethespecificsofaservice• Location• Methods• Allowedmessages• Potentialerrormessages
22
CS4720
QuickSidestep:UDDI• UDDI:UniversalDescription,DiscoveryandIntegration
• Asolutioninsearchofaproblem• Theideaisokay:alanguageandschemaforallowingpeopletopublishtheirWSDLschemassothatotherscandiscovertheirservices
• IBM,Microsoft,andSAPannouncedtheywereclosingtheirpublicUDDInodesinJanuary2006
• Nooneusedit!
24
CS4720
QuickSidestep:UDDI• Wheremightitworkdecently?
– Perhapsinsideasingleorganizationforinternalcode
• Thepublicsideswereeither:– Empty– Overrunwithjunk
• WhicheveritwasUDDI,isn'treallyused• QuoteMartyHumphrey:“Itwasagoodproblemtosolve,butaterriblesolution.”
25
CS4720
BacktoWSDL• WeDOuseWSDLthough• Itishowawebserviceisboundtoanapplication
• It'smoreXML…• But…thebestpartis…
27
CS4720
TheWorstPart• Thiswasreallycomplicated• Evenwithauto-generatingcode,itwastoughtobuildandmaintain
• Itmadeiteasierforwhoeverwantedtoconsumetheservice(theoretically),buteventhentherewasalotofsetup
• PeoplewerealreadystartingtoparsetheirownXMLorJSON…
29
CS4720
ModernRESTAPIs• MostallmodernRESTwebservicesnowoperateusingJSON– JavaScriptObjectNotation– Easytoparse– Easytocreate– MostwebappsarealreadyusingJavaScript,soitworksseamlessly
– JSONparsingisn’texpensiveforotherplatforms
30
CS4720
ModernRESTAPIs• Considerhttps://dev.twitter.com/rest/public• Let’sexaminetheseinthecontextofthefiveaspectsofREST
• ThepurposeofaRESTAPIwebserviceisto:– Exposefunctionalityforotherstouse– Allowthatfunctionalitytobebuiltintootherapps– Makeiteasytouseforvariousplatforms– Stillallowthedevelopertomakemoneysomewayontheservice
31