1 / 50

Service-Oriented Architectures for the Web

Dr Kevin McManus http://staffweb.cms.gre.ac.uk/~mk05/web/dotnet/. Service-Oriented Architectures for the Web. Talk About. What is a Service-Oriented Architecture? Web Services REST, SOAP, WSDL, UDDI Web service integration ASP.NET, PHP Problems with SOA / WS. SOA?.

avak
Download Presentation

Service-Oriented Architectures for the Web

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dr Kevin McManus http://staffweb.cms.gre.ac.uk/~mk05/web/dotnet/ Service-Oriented Architectures for the Web

  2. University of Greenwich Talk About What is a Service-Oriented Architecture? Web Services REST, SOAP, WSDL, UDDI Web service integration ASP.NET, PHP Problems with SOA / WS

  3. University of Greenwich SOA? A paradigm for organizing and utilizing distributed capabilities that may be under the control of different ownership domains† distributed systems architecture views applications as service providers allows other applications to utilise services creating new processes creating new applications creating new business opportunities creating new services † Reference Model for Service Oriented Architecture 1.0, OASIS Standard, 12 October 2006

  4. University of Greenwich S O Architecture Interface driven separation between the interface and the implementation Consumers only need to understand the service description and the service interface Interface is defined by type of messages the service can send and receive

  5. University of Greenwich SO Architectural Principles Reuse, granularity, modularity, componentization, and interoperability Compliance to standards Services identification and categorization Service encapsulation Loose coupling Service contract Service abstraction Service autonomy Service statelessness Service discoverability (source Wikipedia)

  6. University of Greenwich Web Services Enable SOAs for the Web Standards based IETF, W3C, OASIS Contract Driven SOAP + WSDL Self describing WSDL Discoverable UDDI

  7. University of Greenwich HTML, XML HTML HTML XML Generation 1Static HTML Generation 2Web Applications Generation 3Web Services Web ServicesEvolution of the Web

  8. University of Greenwich the web (HTTP) web page LAN or WAN client object server object the web HTTP + XML client object server object Origin of Web Services plus distributed object systems - DCOM, RMI, CORBA resulting in XML based web services

  9. University of Greenwich Web Service Example XML HTTP share price service Brokering application HTML HTTP XML HTTP currency conversion service XML HTTP authentication service

  10. University of Greenwich What is a Web Service? A URI that returns XML A Web Service combines the best features of distributed computing and portals and eliminates the worst Provides a mechanism for invoking methods remotely Uses Web standards i.e. HTTP, XML considered scalable and safe allowed through corporate firewall unlike previous distribution technologies

  11. University of Greenwich What is a Web Service? The solution? A Web Service exposes functionality to a consumer over the Internet or intranet a programmable URL functions you can call over the Internet Based on Web standards HTTP, XML, SOAP, WSDL, UDDI, with more to come Can be implemented in any language on any platform reusable black box components

  12. University of Greenwich Web Services Not tied to any specific implementations Three technologies most often mentioned are: SOAP (Simple Object Access Protocol) provides an XML based protocol for exchanging information WSDL (Web Services Description Language) an XML based language for describing web services and how to access them UDDI (Universal Description, Discovery and Integration specification) a method for publishing and finding web service descriptions e.g. as described in WSDL Other technologies ebXML (ISO, OASIS), WSS, REST (not really a technology)

  13. University of Greenwich What is a Web Service? Web Services allow you to interconnect: different companies many / any devices applications different clients not just browsers Distribution and integration of application logic Enable the programmable (semantic) Web not just the purely interactive Web Web Services are loosely coupled

  14. University of Greenwich SOAP Initially developed by Microsoft as a Simple Object Access Protocol circa 1998 Adopted by W3C in 2000 latest is SOAP version 1.2 2003 A lightweight protocol for exchanging information in a distributed, heterogeneous environment Cross-platform interoperability OS, object model & programming language neutral hardware independent transmission protocol independent works over existing Internet infrastructure

  15. University of Greenwich SOAP Guiding principle: “Invent no new technology” Builds on key Internet standards SOAP ≈ HTTP + XML The SOAP specification defines: the SOAP message format how to send messages how to receive responses data encoding

  16. University of Greenwich SOAP is not… Objects-by-reference remote procedure call distributed garbage collection Push technology bi-directional HTTP Complicated it doesn’t try to solve every distributed computing problem it can be easily implemented

  17. University of Greenwich SOAP SOAP requests are HTTP POST requests POST /WebCalculator/Calculator.asmx HTTP/1.1 Content-Type: text/xml SOAPAction: "http://tempuri.org/Add" Content-Length: 386 <?xml version="1.0"?> <soap:Envelope ...> ... </soap:Envelope>

  18. University of Greenwich SOAP The complete SOAP message SOAP Message Protocol binding headers Headers <Envelope> encloses payload SOAP Envelope <Header> encloses headers SOAP Header Individual headers Headers <Body> contains SOAP message name SOAP Body Message Name & Data XML-encoded SOAP message name & data

  19. University of Greenwich SOAPMessage Format XML document using the SOAP schema <?xml version="1.0"?> <soap:Envelope ...> <soap:Header ...> ... </soap:Header> <soap:Body> <Add xmlns="http://tempuri.org/"> <number1>12</number1> <number2>16</number2> </Add> </soap:Body> </soap:Envelope>

  20. University of Greenwich SOAPServer Response Server responds with a result message HTTP/1.1 200 OK ... Content-Type:text/xml Content-Length: 391 <?xml version="1.0"?> <soap:Envelope ...> <soap:Body> <AddResult xmlns="http://tempuri.org/"> <result>28.0</result> </AddResult> </soap:Body> </soap:Envelope>

  21. University of Greenwich SOAPEncoding Complex Data Data structures are serialized as XML <soap:Envelope ...> <soap:Body> <GetStockDataResult xmlns="http://tempuri.org/"> <result> <Description>Plastic Novelties Ltd</Description> <Price>129</Price> <Ticker>PLAS</Ticker> </result> </GetStockDataRseult> </soap:Body> </soap:Envelope>

  22. University of Greenwich WSDL Web Services Description Language XML schema for describing a Web Service contract Service interface definition abstract semantics for Web Service Service implementation definition concrete end points and network addresses where Web Service can be invoked Describes a set of SOAP messages and how the messages are exchanged

  23. University of Greenwich WSDL <definitions> <types> Data types that are used by the web service (XSD) </types> <message> Defines the data elements of an operation </message> <portType> Describes a web service, the operations that can be performed, and the messages that are involved. </portType> <binding> Defines the message format and protocol details for each port </binding> </definitions>

  24. University of Greenwich UDDI Universal Description, Discovery, and Integration OASIS standard Industry Initiative to address discovery a registration database for Web Services Yellow pages Specifications schema for service providers and descriptions API for publishing and searching developed on industry standards (XML, HTTP, TCP/IP, SOAP) applies to both XML and non-XML services Implementation public and private instances of specification

  25. University of Greenwich REST Representational State Transfer Originally† referred to a collection of architectural principles: a stateless client/server protocol HTTP a set of well-defined operations GET, POST, DELETE a universal syntax for resource-identification URL the use of hypermedia HTML, XML Simply a URL that returns XML † Fielding, Roy T., Architectural Styles and the Design of Network-based Software Architectures, PhD thesis (2000)

  26. University of Greenwich RESTful SOA Next time you find yourself creating a new intranet web page that provides really useful information Think SOA Don’t create a traditional db driven HTML web page Create a restful web service a db driven XML web page accepts GET/POST just like a traditional web page use XSLT to transform the XML into an HTML page People like us will no longer need to screen scrape HTML to use the page to create new / one-off / custom applications

  27. University of Greenwich ASP.NET Fully tooled up support from Visual Studio Microsoft taking a lead Three mouse clicks and your Web Service is fully SOAPed with WSDL and UDDI A number of changes in Visual Studio 2005 mostly improvements

  28. University of Greenwich ASP.NET Web Service Create a new web site and select ASP.NET Web Service Choose File System and your favourite language

  29. University of Greenwich ASP.NET Web Service VS05 gives you a Hello World template

  30. University of Greenwich ASP.NET Web Service Build and run (CtlF5) VS05 fires up a web server on a new port to test the project… … and uses our favourite browser to demonstrate!

  31. University of Greenwich ASP.NET Web Service Follow this link to see the WSDL Follow this link to test the service

  32. University of Greenwich ASP.NET Web Service This HTML form tests the POST service

  33. University of Greenwich ASP.NET Web Service VS05 no longer creates a GET service by default Returned value with XML wrapper

  34. University of Greenwich ASP.NET Web Service Right click the project in the Solution Explorer and add a Web Configuration File

  35. University of Greenwich ASP.NET Web Service Add some stanzas to persuade VS05 to create all three protocols

  36. University of Greenwich ASP.NET Web Service [WebMethod] public string helloWorld(int mess) { if (mess == 1) { return"Hello world :-)"; } else if (mess == 2) { return"Howdy howdy howdy" ; } else { return"I beg your pardon?" ; } } [WebMethod] public string fufu(string foo) { return foo + foo + foo + foo; } Add some code to make the service a little more interesting… … and rebuild

  37. University of Greenwich ASP.NET Web Service VS05 gives us forms to test both web methods

  38. University of Greenwich ASP.NET Web Service So now we want to create a SOAP client to test the SOAP service This is where VS05 runs into some problems Starting a new project kills the web server that VS05 created for us to test our web service We could add a SOAP client to our existing web project but that rather defeats the object of the exercise So try some PHP instead 

  39. University of Greenwich PHP Offered three SOAP implementations NuSOAP ezSOAP PEAR::SOAP All implemented using PHP PHP5 includes a SOAP class created by Zend in C/C++ supports subsets of SOAP 1.1, SOAP 1.2 and WSDL 1.1 specifications

  40. University of Greenwich PHP Instantiate a new SOAP client and tell it where to find the WSDL <?php $client = new SoapClient("http://localhost:1417/WebSite1/Service.asmx?WSDL"); echo$client->helloWorld(2)->helloWorldResult; ?> Call the web method described in the WSDL passing an integer argument with the value 2 and get the result

  41. University of Greenwich PHP This return value has been unpacked from it’s XML wrapper Something wrong here… … it should have replied “Howdy howdy howdy”

  42. University of Greenwich PHP Check the WSDL to see what we are doing wrong Aha! The web method was expecting a complexType

  43. University of Greenwich PHP <?php $client = new SoapClient("http://localhost:1417/WebSite1/Service.asmx?WSDL"); echo$client->helloWorld(array('mess' => 2))->helloWorldResult; ?> The web method expected a name=value pair… … just like GET or POST

  44. University of Greenwich PHP Web Service Client Now that we have figured out how to interface a PHP client to a .NET web service… Create a simple PHP web application that uses the .NET web service a form with two inputs and a submit button not unlike the form that Visual Studio creates to test the web service the application submits form input to itself, passes the input to the web service and returns the result to the user

  45. University of Greenwich <body> <h1> WebSite using SOAP</h1> <form method="post"action="<?php echo $_SERVER['PHP_SELF'] ?>"> <p> <?php $mess = (isset($_POST['mess'])) ? $_POST['mess'] :'1'; $foo = (isset($_POST['foo'])) ? $_POST['foo'] : 'bar'; ?> <input type="text" name="mess" value="<?php echo $mess ?>"/> <input type="text" name="foo" value="<?php echo $foo ?>"/> <input type="submit" /> </p> <p> <?php $mess=(integer)$mess; $client= new SoapClient("http://localhost:1038/WebSite4/Service.asmx?WSDL"); echo($client->helloWorld(array('mess'=>$mess))->helloWorldResult); echo'<br /><br/>'; echo($client->fufu($_POST)->fufuResult); ?> </p> </form> </body> Typecast the string POSTed back from the form $_POST is an array containing the appropriate name value pair

  46. University of Greenwich PHP Consuming ASP.NET web services using PHP has become remarkably simple

  47. University of Greenwich Handling XML Data If you are handling XML data then why bother with all that SOAP? REST places less load on the server so simply return the XML from GET/POST requests So why SOAP? to linearise and ASCII (XML) transport your complicated objects use power tools avoid having to get your hands dirty with XML

  48. University of Greenwich Some Problems Evolving and changing standards Tool support Security (OASIS WSS standard) Versioning XML serialisation is slow XML data is bulky enormous redundancy Why SOAP if you can REST? maybe because you aren’t interested in XML?

  49. University of Greenwich Summary Web Services A new(ish) paradigm for Internet development Deliver applications as services using existing web technologies Third-generation Internet n-tier systems Enabling technology for the semantic web with or without SOAP preferably with WSDL and UDDI More than just hype

  50. University of Greenwich Questions?

More Related