1 / 22

Classic Web access

3. WS need preliminaries. Classic Web access. 1. HTTP Methods. 3. Web Services. Web services: Are typically API or web API that are accessed via HTTP from a client program, and executed on a remote system hosting the requested services. REST ( RESTful). What is REST?

jenis
Download Presentation

Classic Web access

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. 3. WS need preliminaries Classic Web access

  2. 1. HTTP Methods

  3. 3. Web Services Web services: Are typically API or web API that are accessed via HTTP from a client program, and executed on a remote system hosting the requested services.

  4. REST ( RESTful) • What is REST? • An acronym from: Representational State Transfer • An architectural style that is derived by applying a set constraints to the elements of a system so the system exhibits certain properties such as loose coupling and scalability • Defined by Roy T. Fielding, PhD in his PhD dissertation, Chapter 5 Representational State Transfer (REST)Architectural Styles and the Design of Network-based Software Architectures Roy Thomas Fielding, 2000: PhD dissertation, Chapter 5 Representational State Transfer (REST) • Data-orientated, “Unlike the distributed object style , where all data is encapsulated within and hidden by the processing components, the nature and state of an architecture's data elements is a key aspect of REST” • REST: think of the resources: • Any information can be a resource • Their data format (representations with URIs) and • Manipulation through a uniform interface • If REST constraints (see Feildings) aren’t needed then don’t worry about them. An API that has all the REST constraints is a RESTful API.

  5. Resources and representations • Resources r • an abstraction of information: a thing, an entity, an event or “any information that can be named” • identified by URIs, URIs should contain nouns, not verbs • Representations r • information retrieved from a resource • resource data plus meta-data with control data (in HTTP this is the message content and headers)‏ • possible in more than one media type, i.e. a resource could be represented in HTML, XML, JSON, Atom, XHTML or RDF • the current resource state containing data and possibly URIs (links). The URIs are the relationships and application state transitions available from the current representation

  6. When can use REST? When can I use REST? • For Web Services • build your web service using the REST style • alternative to some of WS-*, not a replacement for WS-* • Clients interfacing to public REST APIs • e.g. Amazon S3 REST API, Google Data APIs • 63 percent public APIs have a REST like interface http://www.infoq.com/presentations/Open-API-John-Musser • From Rich Internet Applications (RIAs)‏ • client sends AJAX requests to a REST interface using a JavaScript library e.g. jQuery, Dojo (JsonRestStore) or a framework like JavaFX or Silverlight • response (JSON, XML etc) is displayed on the client

  7. Web API vs. REST Web API using REST principles: • Define the resources • Design the resource representations • HTTP Protocol considerations • response status codes • caching strategy • encodings • Security

  8. 6. Web Service REST - principles Verbs: interface Resource { Resource (URI u); Response get(); Response post(Request r); Response put(Request r); Response delete(); } • Nouns (URL): • http://example.com/customers/1234 • http://example.com/orders/2007/10/776654 • http://example.com/products/4554 • http://example.com/orders/2007/11 • http://example.com/products?color=green • Principles: • Give every resource URL • Link resources together • Use standard methods • Resources with multiple representations • Communicate stateless

  9. 6. REST triangle

  10. REST state full vs. stateless • Disadvantages: • There is currently no industry accepted practice (rules) for expressing priorities, so rules would need to be made. The clients must learn the rule, and the Web service application must be written to understand the rule. • This approach is based upon the incorrect assumption that a URL is "expensive" and that their use must be rationed. • The Web service is a central point of failure. It is a bottleneck. Load balancing is a challenge. State full • Advantages: • The different URLs are discoverable by search engines and UDDI registries. • It's easy to understand what each service does simply by examining the URL, i.e., it exploits the Principle of Least Surprise. • There is no need to introduce rules. • Priorities are elevated to the level of a URL. "What you see is what you get." • It's easy to implement high priority - simply assign a fast machine at the premier member URL. • There is no bottleneck. There is no central point of failure. State less

  11. 6. REST – Pattern example interface Resource { Resource (URIu); Response get(); Response post(Request r); Response put(Request r); Response delete(); }

  12. Exec – URI and HTTP methods • First, only the essential parts of (C#, Java, PHP, Python) sources will be presented. • Next, the complete sources and actions needs for deploy services and clients

  13. RESTful distributions C#: IIS + an *.ashx file Java: RESTeasy, jersey http://jersey.java.net PHP: Da Silva http://diogok.users.phpclasses.org/browse/author/529977.html Python: Django, CherryPy

  14. Examples: exec RESTful implementations

  15. C# calls d:\Florin\Carti\SWMPA\6Rest\Cs\Exec>Rs1Clie Client: C# RESTful http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx/ ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:03:14 PM method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:03:14 PM method GET d:\Florin\Carti\SWMPA\6Rest\Cs\Exec>Rs1Clie http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx Client: C# RESTful http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:03:58 PM method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:03:59 PM method GET d:\Florin\Carti\SWMPA\6Rest\Cs\Exec>Rs1Clie http://localhost:8080/Rj1Serv Client: C# RESTful http://localhost:8080/Rj1Serv ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:03:54 EET 2013 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:03:54 EET 2013 method GET d:\Florin\Carti\SWMPA\6Rest\Cs\Exec>Rs1Clie http://localhost/Rh1Serv.php Client: C# RESTful http://localhost/Rh1Serv.php ping: PHP RESTful localhost (127.0.0.1:80), 2013.03.09 16:04:10 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: PHP RESTful localhost (127.0.0.1:80), 2013.03.09 16:04:10 method GET d:\Florin\Carti\SWMPA\6Rest\Cs\Exec>Rs1Clie http://localhost:3004 Client: C# RESTful http://localhost:3004 ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 4, 27, 652000) method: GET upcase: negru = NEGRU method: GET upcase: negru = NEGRU method: POST add: 66 + 75 = 141 method: PUT add: 66 + 75 = 141 method: DELETE ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 4, 27, 660000) method: GET

  16. Java calls d:\Florin\Carti\SWMPA\6Rest\Java\Exec>java Rj1Clie Client Java RESTful http://localhost:8080/Rj1Serv ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:06:29 EET 2013 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:06:29 EET 2013 method GET d:\Florin\Carti\SWMPA\6Rest\Java\Exec>java Rj1Clie http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx Client Java RESTful http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:07:26 PM method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:07:27 PM method GET d:\Florin\Carti\SWMPA\6Rest\Java\Exec>java Rj1Clie http://localhost:8080/Rj1Serv Client Java RESTful http://localhost:8080/Rj1Serv ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:07:19 EET 2013 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:07:19 EET 2013 method GET d:\Florin\Carti\SWMPA\6Rest\Java\Exec>java Rj1Clie http://localhost/Rh1Serv.php Client Java RESTful http://localhost/Rh1Serv.php ping: PHP RESTful localhost (127.0.0.1:80), 2013.03.09 16:07:37 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: PHP RESTful localhost (127.0.0.1:80), 2013.03.09 16:07:37 method GET d:\Florin\Carti\SWMPA\6Rest\Java\Exec>java Rj1Clie http://localhost:3004 Client Java RESTful http://localhost:3004 ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 7, 46, 885000) method: GET upcase: negru = NEGRU method: GET upcase: negru = NEGRU method: POST add: 66 + 75 = 141 method: PUT add: 66 + 75 = 141 method: DELETE ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 7, 46, 897000) method: GET

  17. PHP calls (1/2)

  18. Python calls (2/2)

  19. Python calls d:\Florin\Carti\SWMPA\6Rest\Python\Exec>python Ry1Clie.py Client Python RESTful http://localhost:3004 ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 23, 11, 869000) method: GET upcase: negru = NEGRU method: GET upcase: negru = NEGRU method: POST add: 66 + 75 = 141 method: PUT add: 66 + 75 = 141 method: DELETE ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 23, 11, 882000) method: GET d:\Florin\Carti\SWMPA\6Rest\Python\Exec>python Ry1Clie.py http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx Client Python RESTful http://win.scs.ubbcluj.ro/~florin/Rs1Serv.ashx ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:24:05 PM method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: C# RESTful win.scs.ubbcluj.ro (172.30.0.14:80) 3/9/2013 5:24:05 PM method GET d:\Florin\Carti\SWMPA\6Rest\Python\Exec>python Ry1Clie.py http://localhost:8080/Rj1Serv Client Python RESTful http://localhost:8080/Rj1Serv ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:23:53 EET 2013 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: Java SOAP: RLF (169.254.214.123:8080), Sat Mar 09 17:23:53 EET 2013 method GET d:\Florin\Carti\SWMPA\6Rest\Python\Exec>python Ry1Clie.py http://localhost/Rh1Serv.php Client Python RESTful http://localhost/Rh1Serv.php ping: PHP RESTful localhost (127.0.0.1:80), 2013.03.09 16:24:06 method GET upcase: negru = NEGRU method GET upcase: negru = NEGRU method POST add: 66 + 75 = 141 method PUT add: 66 + 75 = 141 method DELETE ping: PHP RESTful localhost (127.0.0.1:80), 2013.03.09 16:24:06 method GET d:\Florin\Carti\SWMPA\6Rest\Python\Exec>python Ry1Clie.py http://localhost:3004 Client Python RESTful http://localhost:3004 ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 24, 14, 475000) method: GET upcase: negru = NEGRU method: GET upcase: negru = NEGRU method: POST add: 66 + 75 = 141 method: PUT add: 66 + 75 = 141 method: DELETE ping: Python RESTful Ry1Serv.py RLF(169.254.214.123:3004), datetime.datetime(2013, 3, 9, 17, 24, 14, 495000) method: GET

  20. Android calls

  21. REST ?

  22. TITLU

More Related