Top Banner
CS 4720 Web Services and Service Oriented Architecture CS 4720 – Mobile Application Development
32

Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

Apr 13, 2018

Download

Documents

duongdang
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

WebServicesandServiceOrientedArchitecture

CS4720– MobileApplicationDevelopment

Page 2: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Thetraditionalsoftwaremodel• Organizationsbuilditallfromscratch

– “Wecan'ttrustanyone!Ourcompetitorswillsabotageus!”

– “Wemustowneverything!Hardwareandsoftware!”

• CompaniesthatbuildsoftwareneedcomponentsthatdoXorY…– …sotheybuyCOTScomponents– Servicecontracts,newreleases,regressiontesting…

2

Page 3: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Thetraditionalsoftwaremodel• Howwelldoesthiswork?• SomeprojectdatafromtheDOD:

– 47%ofsoftwaredeliveredcouldnotbeused• Usuallydidn'tmeetrequirements

– 29%offundedsoftwareneverdelivered• Usuallycanceledduetocost/scheduleoverruns

– 19%ofsoftwareusefulafterextensiverework• Costs36timesmoretofixproblemsafterrelease

3

Page 4: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Apushtodistribution• “We'rereallygoodat__________,howcanwegetour__________outforpeopletouse?”

• Theideaofdistributedcomputing– “We'regoodatX,butnotsogoodaY…”– “WhatifwegotsomeonetohelpuswithY…butinawaythatwedidn’thavetoincludeanyfancylibraries…

– …andwecouldusetheminwebapps!Andmobiledevices!Andevendesktopapps!”

4

Page 5: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

AWebService• FromW3C:“asoftwaresystemdesignedtosupportinteroperablemachine-to-machineinteractionoveranetwork.Ithasaninterfacedescribedinamachine-processableformat(specificallyWSDL).OthersystemsinteractwiththeWebserviceinamannerprescribedbyitsdescriptionusingSOAP-messages,typicallyconveyedusingHTTPwithanXMLserializationinconjunctionwithotherWeb-relatedstandards”

5

Page 6: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

AWebService?• Huh?• Abitmoresimply:Aprogram,accessibleviatheInternet,thatcandosomefunction(eitherforfreeorafee)andcanbedynamicallydiscoveredandused.

• So…Iusewebappsallthetime…arethosewebservices?

6

Page 7: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

WebServiceasRPC• Theearliestformofatrue“webservices” wasanRPC– remoteprocedurecall.

• Exactlywhatitsoundslike– thereisanexposedfunction/methodthatisaccessedviathewebwhereyoupasstheparametersandthemethodnameandyougetbackareturnvalue.

• NoticehowthisisverydifferentfromtheRESTfulmodel(verbsvs.nouns)

7

Page 8: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

WebServiceasSOA• RPCwasokay…butitturnedouttobeabitmorelanguagespecificthanwe'dlike

• Whatifwejustastructuredmessage(likeanXMLdocument)thatdescribedwhatwewanted,asopposedtoknowingtheexactfunctioncall?

• ThisisthebasisoftheService-OrientedArchitecture

8

Page 9: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

WordByWord• Whatisaservice?• "Aserviceisadiscoverableresourcethatexecutesarepeatabletask,andisdescribedbyanexternalizedservicespecification.”

• Businessalignment– businessrequirements• Specifications– self-contained,wellspecified• Reusability– generalenoughtobereused• Agreements– basedonfunction,notplatform• Hostinganddiscoverability– available• Aggregation– canbecombinedtomakebiggerservices

9

Page 10: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

WordByWord• Whatisanarchitecture?• "Aformaldescriptionofasystem,oradetailedplanofthesystematcomponentleveltoguideitsimplementation.”

• “Thestructureofcomponents,theirinterrelationships,andtheprinciplesandguidelinesgoverningtheirdesignandevolutionovertime."

10

Page 11: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Architecture

11

• Architectureis:– Ahigh-enoughlevelofabstractionthatthesystemcanbeviewedasawholeandyetstillprovidesenoughinformationtomakedecisions.

– Supportsthefunctionalityofthesystem.– Allimplementationdetailsarehidden.

• Serviceorientationisawayofintegratingabusinessasasetoflinkedservices.

Page 12: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

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

Page 13: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

SOA– TheQuickVersion• Rightnow,youprobablythinkofasoftwaresystemasbeingacollectionofclasses/objects

• Butusersdon'tthinkofsystemslikethat…theythinkofsystemsassetsoffunctionalitythathelpthemdosomething

• So…whydoweuseobjects?– Easiertomodel– Easiertoprogram– Easiertoexplaintootherprogrammers

13

Page 14: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Orisitactuallyeasier?• Turnourideaofasystem90degrees• Functionalityobjects(proceduralabstraction)isthekeyidea,notworldobjects(dataabstraction)

• ThisisthekeyinSOA– AnSOAsystemhasthefunctionalitiesasthemainplayers,nottheobjectsthemselves

– Butmoreso,theseservicesareprovidedbymanydifferentplayers

14

Page 15: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Butwhatlanguagedowespeak?• OneearlywaytodowebserviceswaswithSOAP

• SOAP- SimpleObjectAccessProtocol– Acommunicationprotocol– Aformatforsendingmessages– XMLbased

• NotreallymuchmorethananHTTPrequestthatfollowsXML/SOAPstandards

15

Page 16: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

SOAPModel

16

Page 17: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

SOAPModel

17

Page 18: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

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

Page 19: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

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

Page 20: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

PartsofSOAP• TheEnvelope– requiredrootelementdefiningthedocumentasbeingaSOAPrequest

• TheHeader– notrequired,butcontainsauthenticationand/orpaymentinfofortherequest

• TheBody– theactualmessagebeingsent

20

Page 21: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

UsingaWebService• Ifyoutookthetimetocreateaservice,thenyouprobablywantpeopletouseit

• Inordertouseaservice,usersneedtoknowwhatinformationtheycansendtheserviceandwhatinformationisgoingtobesentback

• Whatwouldbeevenbetterisifthesoftwarecoulddoallthisautomatically…

21

Page 22: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

EnterWSDL• WSDL:WebServicesDescriptionLanguage

– AnXMLdocumentusedtogivethespecificsofaservice• Location• Methods• Allowedmessages• Potentialerrormessages

22

Page 23: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

EnterWSDL

23

Page 24: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

QuickSidestep:UDDI• UDDI:UniversalDescription,DiscoveryandIntegration

• Asolutioninsearchofaproblem• Theideaisokay:alanguageandschemaforallowingpeopletopublishtheirWSDLschemassothatotherscandiscovertheirservices

• IBM,Microsoft,andSAPannouncedtheywereclosingtheirpublicUDDInodesinJanuary2006

• Nooneusedit!

24

Page 25: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

QuickSidestep:UDDI• Wheremightitworkdecently?

– Perhapsinsideasingleorganizationforinternalcode

• Thepublicsideswereeither:– Empty– Overrunwithjunk

• WhicheveritwasUDDI,isn'treallyused• QuoteMartyHumphrey:“Itwasagoodproblemtosolve,butaterriblesolution.”

25

Page 26: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

TheOriginalIdea

26

Page 27: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

BacktoWSDL• WeDOuseWSDLthough• Itishowawebserviceisboundtoanapplication

• It'smoreXML…• But…thebestpartis…

27

Page 28: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

TheBestPartaboutWSDL• Nooneeverwritesthestuffthemselves!• It'sauto-generated!

28

Page 29: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

TheWorstPart• Thiswasreallycomplicated• Evenwithauto-generatingcode,itwastoughtobuildandmaintain

• Itmadeiteasierforwhoeverwantedtoconsumetheservice(theoretically),buteventhentherewasalotofsetup

• PeoplewerealreadystartingtoparsetheirownXMLorJSON…

29

Page 30: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

ModernRESTAPIs• MostallmodernRESTwebservicesnowoperateusingJSON– JavaScriptObjectNotation– Easytoparse– Easytocreate– MostwebappsarealreadyusingJavaScript,soitworksseamlessly

– JSONparsingisn’texpensiveforotherplatforms

30

Page 31: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

ModernRESTAPIs• Considerhttps://dev.twitter.com/rest/public• Let’sexaminetheseinthecontextofthefiveaspectsofREST

• ThepurposeofaRESTAPIwebserviceisto:– Exposefunctionalityforotherstouse– Allowthatfunctionalitytobebuiltintootherapps– Makeiteasytouseforvariousplatforms– Stillallowthedevelopertomakemoneysomewayontheservice

31

Page 32: Web Services and Service Oriented Architecture Services and Service Oriented Architecture CS 4720 –Mobile Application Development CS 4720 The traditional software model •Organizations

CS4720

Whichbringsusbacktomobile!• Withmobile:

– WelikeREST!Itworkswellwithnetworkthatcomesandgoesandhowweusemobiledevices!

– WelikeMVC!Itmakessenseinhowwebuildourapps!

– Welikewebservices!Itallowsustoutilizepowerfulfeaturesdevelopedbyotherstomakeourownappsevenbetter!

– Now… howdowedoit???

32