1 / 53

Web Services

Web Services. Dongwon Lee, Ph.D. IST 516 Fall 2011. Web Services.

fcunningham
Download Presentation

Web Services

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. Web Services Dongwon Lee, Ph.D. IST 516 Fall 2011

  2. Web Services • “Web services are a new breed of Web application. They are self-contained, self-describing, modular applications that can be published, located, and invoked across the Web. Web services perform functions, which can be anything from simple requests to complicated business processes...Once a Web service is deployed, other applications (and other Web services) can discover and invoke the deployed service…” • Mark Colan, IBM, 2004 • http://www.ibm.com/developerworks/webservices/library/ws-soaintro.html

  3. Web Services • “A software system designed to support interoperable machine-to-machine interaction over a network…” • W3C: http://www.w3.org/TR/ws-gloss/ • “Web Services allow programs written in different programming languages on different platforms to communicate each other in a standards-based way”, • Roger Wolter, Microsoft, 2001 • http://msdn.microsoft.com/en-us/library/ms996507.aspx

  4. Web Services Forecast (2007) [ Gartner report] • Estimated that revenue for Web-services-enabled software and professional services will grow from $61 billion (2003) to $316 billion Dollars in Billions $316 billion $250 $271 200 150 100 $45 0 Web-Services-Enabled Software Products IT Professional Services forWeb-Services Projects

  5. WS-related Standards and Orgs.

  6. WS-related Tech. Life-Cycles[Gartner, 2004] Key: Time to Plateau Visibility Opportunistic SODA Opportunities (12 to 18 months) Strategic SODA Opportunities(18 to 36 months) Supportive Technology (Foundational) Advanced Web Services (BPEL, WSS, WS TX) Packaged Integrating Processes BPM Transf. and Routing MOM EDI Adapters BAM JCA XML CORBA Mobile Middleware RosettaNet Integration Broker Suites ESB ebXML ProgrammaticInteg. Servers EventMgmt. Bus. Rule Engines Basic Web Services (WSDL, SOAP, UDDI) Ontology-Based Transformation Agents As of August 2003 Technology Trigger Peak of Inflated Expectations Trough of Disillusionment Slope of Enlightenment Plateau of Productivity Time

  7. Hype Cycle for Web and User Interaction Tech. [Gartner, 2010]

  8. Two Camps of Web Services • Standard based • SOAP, UDDI, WSDL • WS-I, WS-Security, … • Heavyweight • More powerful • SOA (service-oriented architecture) initially started with SOAP camp • No standards • Lightweight • Faster/easier to develop • Architectural style closer to WWW • Recently more popular SOAP Camp REST Camp

  9. #1. SOAP Based Web Services

  10. Common Flow

  11. Generic Architecture Web Services on the Web Internet Your Company Web Server Firewall Application Server Web Services on the Intranet Middle-tier DB Internal DB Existing Systems Legacy Systems

  12. WS Platform • Web Service is • XML plus • HTTP plus • SOAP plus • WSDL plus • UDDI plus • And lots of other WS standards • Eg, WS-I, WS-Security, XAML, XLANG, XKMS, XFS, …

  13. WS Platform • Web Service is • XML • HTTP -- transport • SOAP -- remote invocation • WSDL -- API • UDDI -- directory service

  14. SOAP • The name of the SOAP Camp Web Services got originated from a protocol called SOAP • Simple Object Access Protocol • A HTTP-based protocol specification that defines a uniform way of passing XML-encoded data • Similar to RPC (Remote Procedure Call) in old days

  15. UDDI • Universal Description, Discovery and Integration Service • UDDI provides a mechanism for client programs to dynamically find other web services • White (address, contact, etc), Yellow (industry categorization), Green (technical details) pages • Similar to CORBA trader or DNS service

  16. Eg, Xmethods.net

  17. WSDL • Web Services Definition Language • V2.0, 2007 • http://www.w3.org/TR/wsdl20-primer/ • WSDL provides a way for service providers to describe the basic format of web service requests over different protocols or encodings • WSDL is used to describe what a web service can do, where it resides, and how to invoke it • Similar to IDL of CORBA in concept

  18. WS Implementation Big Picture Android Linux UDDI Windows Find WSDL C++ Client Publish Java Client Perl Client Web Service Implementation Python Client Invoke SOAP

  19. Ex 1. Google Search WS • Client wants to write a software program that can connect to the Google, issues some query search, and retrieves answers from it • Google built Web Service implementation in their server, and published the information in the UDDI already • By looking at its WSDL, one knows what kind of APIs Google provides

  20. GoogleSearch.wsdl • http://api.google.com/GoogleSearch.wsdl • Note: This link no longer works – • just use this to understand the • concept of traditional approach

  21. Ex 1. Google Search WS • WSDL has APIs like: • doGoogleSearch(string keyword) • This function returns search results in XML format to the client UDDI WSDL Publish Google Web Service Implementation SOAP

  22. Java Client Example package com.google.soap.search; … GoogleSearch s = new GoogleSearch(); s.setQueryString(“xml database”); GoogleSearchResult r = s.doGoogleSearch(); System.out.println(r.toString()); …

  23. Ex 1. Google Search WS UDDI WSDL Publish Java Client doGoogleSearch(“xml database”) In XML format Google Web Service Implementation SOAP

  24. SOAP Request Example <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <key xsi:type="xsd:string">00000000000000000000000000000000</key> <q xsi:type="xsd:string">xml database</q> <start xsi:type="xsd:int">0</start> <maxResults xsi:type="xsd:int">10</maxResults> <filter xsi:type="xsd:boolean">true</filter> <restrict xsi:type="xsd:string"></restrict> <safeSearch xsi:type="xsd:boolean">false</safeSearch> <lr xsi:type="xsd:string"></lr> <ie xsi:type="xsd:string">latin1</ie> <oe xsi:type="xsd:string">latin1</oe> </ns1:doGoogleSearch> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

  25. SOAP Response Example <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:doGoogleSearchResponse xmlns:ns1="urn:GoogleSearch" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="ns1:GoogleSearchResult"> <documentFiltering xsi:type="xsd:boolean">false</documentFiltering> <estimatedTotalResultsCount xsi:type="xsd:int">3</estimatedTotalResultsCount> <directoryCategories xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:Array" ns2:arrayType="ns1:DirectoryCategory[0]"></directoryCategories> <searchTime xsi:type="xsd:double">0.194871</searchTime> <resultElements xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Array" ns3:arrayType="ns1:ResultElement[3]"> <item xsi:type="ns1:ResultElement"> <cachedSize xsi:type="xsd:string">12k</cachedSize> <hostName xsi:type="xsd:string"></hostName> <snippet xsi:type="xsd:string"> &lt;b&gt;...&lt;/b&gt; on a simple dialog (via &lt;b&gt;teletype&lt;/b&gt;) with a user, about a &lt;b&gt;...&lt;/b&gt; http://hci.stanford.edu/&lt;b&gt;winograd&lt;/b&gt;/&lt;b&gt;shrdlu&lt;/b&gt;&lt;br&gt; . It is written in &lt;b&gt;MacLisp&lt;/b&gt;, vintage 1970, and to &lt;b&gt;...&lt;/b&gt;</snippet> <directoryCategory xsi:type="ns1:DirectoryCategory"> <specialEncoding xsi:type="xsd:string"></specialEncoding> <fullViewableName xsi:type="xsd:string"></fullViewableName> </directoryCategory> <relatedInformationPresent xsi:type="xsd:boolean">true</relatedInformationPresent> <directoryTitle xsi:type="xsd:string"></directoryTitle> <summary xsi:type="xsd:string"></summary> <URL xsi:type="xsd:string">http://hci.stanford.edu/cs147/examples/shrdlu/</URL> <title xsi:type="xsd:string">&lt;b&gt;SHRDLU&lt;/b&gt;</title> </item> …

  26. #2. RESTful Web Services

  27. HTTP Request Methods • HTTP can use different request methods (aka “verbs”) to describe an action to be performed on the resource in the server • Resource could be existing or dynamically-generated file • HTTP Request line has 3 components: GET /path/to/file/index.html HTTP/1.0 • Two most commonly used verbs • GET: to read resources • POST: to read, update, delete, create resources

  28. HTTP GET vs. POST • GET method sends only a URL and headers to the server • POST method sends a message body as well • GET uses URL-encoded data, appended to URL: • Eg, http://foo.bar.com/search?name1=value1&name2=value2$name3=value3 • POST is used when the client needs to send data to the server as part of the request • Eg, uploading a file or submitting a completed form to CGI script

  29. REST as Alternative • REST: REpresentational State Transfer • An architectural style for large-scale software design by R. Fielding in 2000 • REST based Web Services • Called “RESTful” • Underpinnings of World-Wide Web (WWW) • Stateless client/server architecture • Resources with ID (eg, web site with URL): named resources • Global methods (eg, POST/GET)

  30. REST as Alternative • REST allows client to access “any” resources using HTTP GET/POST request as long as they publish their ID (such as URI) • No need to use WSDL or SOAP explicitly • Many modern web services interface support (only) RESTful style • (SOAP-based) Web Services client cannot access resources unless they publish specific API (eg, WSDL) in UDDI • Two different “styles” of web s/w architecture

  31. REST as Non-Standard • Unlike SOAP based web services, REST is NOT a web standard (but uses web standards such as XML, HTTP, etc) • No W3C standard specification • No vendor selling s/w for you to write REST • Architectural Style

  32. Directory for REST Camp • SOAP camp has a directory system—UDDI server • UDDI enables machines to search and discover relevant web services and their info • Can be automated w/o human involvement • REST does not have equivalent directory • Only directory system where human users have to navigate • Manual approach • Eg, ProgrammableWeb • http://www.programmableweb.com/

  33. ProgrammableWeb: 3,990 WS (2011) SOAP style: 661 web services REST style: 2,814 web services

  34. Google’s Approach to WS • Google used to support the traditional SOAP based WS • “procedure-call” approach for web services • From 2007, Google only supports RESTful approach for web services • In particular, Google web services use AJAX framework

  35. Web as Client & Server Architecture Request Client (IE, Firefox, Opera) Response

  36. Web as Client & Server Architecture hello.htm <html><body>Hello World!</body></html> Request:http://pike.psu.edu/hello.htm Connect me to: pike.psu.edu I want file: hello.htm “Explain” Response

  37. Dynamic Server We want a piece of code that really “runs” on the client or server side Generate different result under different conditions Two kinds of scripts: Client side script: running at client side, i.e., in your browser. Server side script: running at server side, give you the result in the form of pure HTML Eg, PHP-embedded HTML pages

  38. Server Side Script: “Say date” execution date.php <html><body><?echo date(“l, F d Y”)?></body></html> Request:http://pike.psu.edu/date.php Connect me to: pike.psu.edu I want file: date.php This is PHP code <html><body>Tuesday, October 04 2005</body></html> “Explain” Response PHP output here.

  39. Client Side Script: AJAX • AJAX: Asynchronous JAva script and Xml • Coined around 2005 • Framework to build interactive web applications • Before: web pages need to be re-loaded each time if users want to see different datasets • After: by separating web pages and data items (ie, asynchronous), AJAX improves dynamic user interfaces significantly • Typically uses • XHTML + CSS • JavaScript, Jscript • XML + Web Service Concept

  40. Google WS APIs http://code.google.com/more/

  41. Preparation https://explorer.pass.psu.edu/explorer.cgi Will use the following URL as the directory containing my web service examples: http://www.personal.psu.edu/dul13/ws

  42. Preparation • You need to have a Google Account • https://www.google.com/accounts/ • Obtain a KEY to use Google AJAX API • http://code.google.com/apis/loader/signup.html URL to my prepared folder in the PASS

  43. Preparation • KEY: unique identifier for each request to Google • <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=ABQIAAAAgzmwIE9Rku8gDp56FO8MBxRViFCnk6CL9JYCTwwFakTbqfC3xRnanohKD1AviW_9EaTVUvdh2Bmuw" type="text/javascript"></script>

  44. Languages to Support • Google AJAX supports many programming languages • Javascript • Python • Java • Perl • PHP • Flash • … We will use Javascript to explain examples

  45. Ex 1: Hello World http://www.personal.psu.edu/dul13/ws/hello.html • Copy AJAX example to an HTML file, upload it to PASS and access it

  46. Ex 2: Hello World with TAB • Modify code in “hello.html” to see different effects  “hello-tab.html” • Eg, Tabbed results Use online documentation at http://code.google.com/apis/websearch/docs/ // tell the searcher to draw itself in tabbed modedrawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);searchControl.draw(element, drawOptions);

  47. Example Javascript + HTML • Download 3 files to your PASS and play with them: • http://www.personal.psu.edu/dul13/ws/hello.html • http://www.personal.psu.edu/dul13/ws/hello-tab.html • http://www.personal.psu.edu/dul13/ws/map.html • Lots of RESTful WS examples from Google: • http://code.google.com/more/

  48. Other Similar Web APIs • Similar to Google’s AJAX based Search WS • Yahoo BOSS (Build your Own Search Service) • http://developer.yahoo.com/search/boss/

  49. Other Similar Web APIs • Microsoft BING Maps AJAX APIs • http://www.microsoft.com/maps/developers/web.aspx • Many examples using BING Maps

  50. NEW: RESTful Custom Search http://code.google.com/apis/customsearch/v1/using_rest.html

More Related