Web Services and Service Oriented Architecture
Total Page:16
File Type:pdf, Size:1020Kb
Web Services and Service Oriented Architecture CS 4720 – Web & Mobile Systems CS 4720 The tradi0onal so5ware model • Organizaons build it all from scratch – “We can't trust anyone! Our compe0tors will sabotage us!” – “We must own everything! Hardware and so5ware!” • Companies that build so5ware need components that do X or Y… – … so they buy COTS components – Service contracts, new releases, regression tes0ng… 2 CS 4720 The tradi0onal so5ware model • How well does this work? • Some project data from the DOD: – 47% of so5ware delivered could not be used • Usually didn't meet requirements – 29% of funded so5ware never delivered • Usually canceled due to cost/schedule overruns – 19% of so5ware useful aer extensive rework • Costs 36 0mes more to fix problems aer release 3 CS 4720 A push to distribu0on • “We're really good at __________, how can we get our __________ out for people to use?” • The idea of distributed compu0ng – “We're good at X, but not so good a Y…” – “What if we got someone to help us with Y… but in a way that we didn’t have to include any fancy libraries… – … and we could use them in web apps! And mobile devices! And even desktop apps!” 4 CS 4720 A Web Service • From W3C: “a so5ware system designed to support interoperable machine-to-machine interac0on over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its descrip0on using SOAP-messages, typically conveyed using HTTP with an XML serializaon in conjunc0on with other Web- related standards” 5 CS 4720 A Web Service? • Huh? • A bit more simply: A program, accessible via the Internet, that can do some func0on (either for free or a fee) and can be dynamically discovered and used. • So… I use web apps all the 0me… are those web services? 6 CS 4720 Web Service as RPC • The earliest form of a true “web services” was an RPC – remote procedure call. • Exactly what it sounds like – there is an exposed func0on/method that is accessed via the web where you pass the parameters and the method name and you get back a return value. • No0ce how this is very different from the RESTful model (verbs vs. nouns) 7 CS 4720 Web Service as SOA • RPC was okay… but it turned out to be a bit more language specific than we'd like • What if we just a structured message (like an XML document) that described what we wanted, as opposed to knowing the exact func0on call? • This is the basis of the Service-Oriented Architecture 8 CS 4720 Word By Word • What is a service? • "A service is a discoverable resource that executes a repeatable task, and is described by an externalized service specifica:on.” • Business alignment – business requirements • Specificaons – self-contained, well specified • Reusability – general enough to be reused • Agreements – based on func0on, not plaorm • Hos0ng and discoverability – available • Aggregaon – can be combined to make bigger services 9 CS 4720 Word By Word • What is an architecture? • "A formal descrip:on of a system, or a detailed plan of the system at component level to guide its implementa:on.” • “The structure of components, their interrela:onships, and the principles and guidelines governing their design and evolu:on over :me." 10 CS 4720 Architecture • Architecture is: – A high-enough level of abstrac0on that the system can be viewed as a whole and yet s0ll provides enough informaon to make decisions. – Supports the func0onality of the system. – All implementaon details are hidden. • Service orienta:on is a way of integra:ng a business as a set of linked services. 11 CS 4720 What are we actually trying to do? Fork Receive PO Update Customer Profile Get Items from Inventory Branch Compute Subtotal Compute Export Tax [ship within US] [ship outside US] Compute Shipping Cost Merge Compute International Shipping Compute Total Ship Order Join 12 CS 4720 OSI Model 13 CS 4720 OSI Model 14 CS 4720 The Stack 15 CS 4720 The Stack ebXML UDDI Registries Discovery ebXML Contracts and CPA agreements OWL-S Service Process and workflow BPEL4WS BPML Model orchestrations WS-AtomicTransaction and WS- BTP QoS: Transactions BusinessXALcAtiNviGty WS-Reliable OWL-WS SSCeLrvice WS-Coordination QoS: Choreography Messaging ebXML Profile WSCI BPSS OWL-S Service WS-Security WSCL QoS: Conversations Grounding ebXML WS-Policy WSDL QoS: Service OWL PSL CPP descriptions and bindings ebXML RDF SOAP messaging Messaging XML, DTD, and XML Schema Encoding HTTP, FTP, SMTP, SIP, etc. Transport 16 CS 4720 The Stack 17 CS 4720 SOA – The Quick Version • Right now, you probably think of a so5ware system as being a collec0on of classes / objects • But users don't think of systems like that… they think of systems as sets of func0onality that help them do something • So… why do we use objects? – Easier to model – Easier to program – Easier to explain to other programmers 18 CS 4720 Or is it actually easier? • Turn our idea of a system 90 degrees • Func0onality objects (procedural abstrac0on) is the key idea, not world objects (data abstrac0on) • This is the key in SOA – An SOA system has the func0onali0es as the main players, not the objects themselves – But more so, these services are provided by many different players 19 CS 4720 But what language do we speak? • SOAP - Simple Object Access Protocol – A communicaon protocol – A format for sending messages – Plaorm independent – XML based – Follows the rules that allow for transmission easily over HTTP, SMTP, etc. • Not really much more than an HTTP request that follows XML/SOAP standards 20 CS 4720 SOAP Model 21 CS 4720 SOAP Model 22 CS 4720 SOAP Request POST /InStock HTTP/1.1! Host: www.example.org! Content-Type: application/soap+xml; charset=utf-8! Content-Length: nnn" " <?xml version="1.0"?>" <soap:Envelope" xmlns: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>! 23 CS 4720 SOAP Response • HTTP/1.1 200 OK" Content-Type: application/soap+xml; charset=utf-8" Content-Length: nnn" " <?xml version="1.0"?>" <soap:Envelope" xmlns: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>! 24 CS 4720 Parts of SOAP • The Envelope – required root element defining the document as being a SOAP request • The Header – not required, but contains authen0caon and/or payment info for the request • The Body – the actual message being sent 25 CS 4720 But I like to be dirty! • …. • Bad 0tle aside, some didn't like to be “ed down” by such “conservave talk” of having to follow the SOAP rules! • “It's just XML!” they said. “I don't need of this extra stuff! Just good Plain Old XML…!” • “And that's what we'll call it! POX!” 26 CS 4720 What's the difference? • Following the agreed upon rules… • Validang POX can be hard; SOAP is comparably easy • SOAP services are beqer at being dynamically bound • How we do this is Thursday's lecture 27 CS 4720 A5er all this… What about REST? • REST is an architectural style that is independent, but compable, with XML • POX/HTTP means exchanging plain old XML documents over HTTP; can be RESTful • SOAP is a standard document format for building high-level protocols. Anything that uses SOAP is (by defini0on) not just using plain old XML, and thus not POX; it can also be RESTful 28 CS 4720 So… • So there can be RESTful SOAP applicaons, and RESTful POX applicaons, and non-RESTful SOAP applicaons, and non-RESTful POX applicaons, but no POX/SOAP combinaon… sort of 29 CS 4720 Thoughts • If you want a great experience for .NET/Java devs, you'll typically publish schemas and support SOAP. • If you want a great experience for LAMP folks, you'll support POX messages (or JSON) and will provide a non-XSD descrip0on of your formats. • If you want to reach both audiences, you'll do both #1 and #2. • If you want to reach both audiences before your compeon does, you'll avoid indulging in religious debates and ship something. 30 CS 4720 Using a Web Service • If you took the 0me to create a service, then you probably want people to use it • In order to use a service, users need to know what informaon they can send the service and what informaon is going to be sent back • What would be even beqer is if the so5ware could do all this automacally… 31 CS 4720 Enter WSDL • WSDL: Web Services Descrip0on Language – An XML document used to give the specifics of a service • Locaon • Methods • Allowed messages • Poten0al error messages 32 CS 4720 Enter WSDL 33 CS 4720 The HelloService Example • hqp://oreilly.com/catalog/webservess/ chapter/ch06.html 34 CS 4720 Quick Sidestep: UDDI • UDDI: Universal Descrip0on, Discovery and Integraon • A solu0on in search of a problem • The idea is okay: a language and schema for allowing people to publish their WSDL schemas so that others can discover their services • IBM, Microso5, and SAP announced they were closing their public UDDI nodes in January 2006 • No one used it! 35 CS 4720 Quick Sidestep: UDDI • Where might it work decently? – Perhaps inside a single organizaon for internal code • The public sides were either: – Empty – Overrun with junk • Whichever it was UDDI, isn't really used • Quote Marty Humphrey: “It was a good problem to solve, but a terrible solu0on.” 36 CS 4720 The Original