12 Web Services REresentation State Transfer (REST) CA464: DISTRIBUTED PROGRAMMING 1. More on Distributed Web Services: REST

Similar documents
02267: Software Development of Web Services

02267: Software Development of Web Services

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

XML Processing and Web Services. Chapter 17

EUR-Lex 2012 Data Extraction using Web Services

Distribution and Integration Technologies

Integrating Complementary Tools with PopMedNet TM

Contents. 2 Alfresco API Version 1.0

Session 6 Patterns and best practices in SOA/REST

Designing RESTful Web Applications

REST vs. SOAP: Making the Right Architectural Decision

Mobility Information Series

Lesson 4 Web Service Interface Definition (Part I)

REST API Development. B. Mason Netapp E-Series

The presentation explains how to create and access the web services using the user interface. WebServices.ppt. Page 1 of 14

REST web services. Representational State Transfer Author: Nemanja Kojic

Some REST Design Patterns (and Anti-Patterns)

Secure Coding SSL, SOAP and REST. Astha Singhal Product Security Engineer salesforce.com

CA Nimsoft Service Desk

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

WEB SERVICES. Revised 9/29/2015

Oracle Service Bus Examples and Tutorials

HTTP - METHODS. Same as GET, but transfers the status line and header section only.

CS169.1x Lecture 5: SaaS Architecture and Introduction to Rails " Fall 2012"

Leveraging Cloud Storage Through Mobile Applications Using Mezeo Cloud Storage Platform REST API. John Eastman Mezeo

in Cloud Environment Contributors: Wednesday March 30, 2011

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Dell One Identity Cloud Access Manager How to Develop OpenID Connect Apps

HOST EUROPE CLOUD STORAGE REST API DEVELOPER REFERENCE

T320 E-business technologies: foundations and practice

Literature Review Service Frameworks and Architectural Design Patterns in Web Development

vcloud Air Platform Programmer's Guide

An Oracle White Paper June RESTful Web Services for the Oracle Database Cloud - Multitenant Edition

WIRIS quizzes web services Getting started with PHP and Java

Enabling REST Services with SAP PI. Michael Le Peter Ha

REST services in Domino - Domino Access Services

September 2009 Cloud Storage for Cloud Computing

Specifying the content and formal specifications of document formats for QES

SafeNet KMIP and Google Cloud Storage Integration Guide

Web Services Description Language (WSDL) Wanasanan Thongsongkrit

Java Web Services Training

Message Containers and API Framework

Accessing Data with ADOBE FLEX 4.6

To begin, visit this URL:

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

The end. Carl Nettelblad

Performance Testing Web 2.0

ACM Crossroads Student Magazine The ACM's First Electronic Publication

Using Hypermedia Services for Systems Integration. Tim Ewald Systems Engineer

Dynamic Decision-Making Web Services Using SAS Stored Processes and SAS Business Rules Manager

Integrating CRM On Demand with the E-Business Suite to Supercharge your Sales Team

Web Container Components Servlet JSP Tag Libraries

Easy CramBible Lab DEMO ONLY VERSION Test284,IBM WbS.DataPower SOA Appliances, Firmware V3.6.0

Oct 15, Internet : the vast collection of interconnected networks that all use the TCP/IP protocols

Building Java Servlets with Oracle JDeveloper

HireDesk API V1.0 Developer s Guide

vcommander will use SSL and session-based authentication to secure REST web services.

Replacements TECHNICAL REFERENCE. DTCCSOLUTIONS Dec Copyright 2009 Depository Trust Clearing Corporation. All Rights Reserved.

Building and Using Web Services With JDeveloper 11g

Types of Cloud Computing

Web Services ( )

On-Demand Business Process Integration Based on Intelligent Web Services

Qlik REST Connector Installation and User Guide

docs.rackspace.com/api

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

Cloud Elements! Events Management BETA! API Version 2.0

Web Services Tutorial

Why API? Using the REST API in an education environment. JAMF Software, LLC

Introduction to Web Services

10CS73:Web Programming

CONTRACT MODEL IPONZ DESIGN SERVICE VERSION 2. Author: Foster Moore Date: 20 September 2011 Document Version: 1.7

FF/EDM Intro Industry Goals/ Purpose Related GISB Standards (Common Codes, IETF) Definitions d 4 d 13 Principles p 6 p 13 p 14 Standards s 16 s 25

Want to read more? You can buy this book at oreilly.com in print and ebook format. Buy 2 books, get the 3rd FREE!

Lightweight Data Integration using the WebComposition Data Grid Service

Introduction to CloudScript

Using Web Services to Exchange data with Qualtrics and Hobsons Connect

APACHE WEB SERVER. Andri Mirzal, PhD N

Module 4: File Reading. Module 5: Database connection

10. Java Servelet. Introduction

Fairsail REST API: Guide for Developers

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

StreamServe Persuasion SP4 Service Broker

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Integration the Web 2.0 way. Florian Daniel April 28, 2009

IBM Cloud Manager with OpenStack. REST API Reference, version 4.1

Cloud Elements! Marketing Hub Provisioning and Usage Guide!

Business Process Management IBM Business Process Manager V7.5

How to consume a Domino Web Services from Visual Studio under Security

VPN. Date: 4/15/2004 By: Heena Patel

Ambientes de Desenvolvimento Avançados

Selenium WebDriver. Gianluca Carbone. Selenium WebDriver 1

Integration of Hotel Property Management Systems (HPMS) with Global Internet Reservation Systems

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Siebel Web UI Dynamic Developer Kit Guide. Siebel Innovation Pack 2013 Version 8.1/8.2 September 2013

REST (Representa.onal State Transfer) Ingegneria del So-ware e Lab. Università di Modena e Reggio Emilia Do<. Marzio Franzini

Using Online Storage Services

IJISET - International Journal of Innovative Science, Engineering & Technology, Vol. 1 Issue 7, September

ISSUES ON FORMING METADATA OF EDITORIAL SYSTEM S DOCUMENT MANAGEMENT

WEB SERVICES TEST AUTOMATION

Transcription:

CA464: DISTRIBUTED PROGRAMMING 1 12 Web Services 12.1 REresentation State Transfer (REST) More on Distributed Web Services: REST Architecture REST, or Representational State Transfer, is a distributed communication architecture fast becoming the lingua franca for Cloud Computing. The central abstraction in REST is the Resource. A resource in the RESTful sense is anything that has an URI. In practice, a resource is an informational item that has hyperlinks to it. Contrast Between SOAP & REST Essence: REST & SOAP are quite different SOAP is a messaging protocol, REST is a architectural style. SOAP uses WSDL for comms, REST exchanges data in XML/JSON 1. SOAP calls services by RPCs, REST invokes them via URL path. SOAP can be over other protocols, REST is only over HTTP. 1 a more lightweight, human parsable data exchange format than XML

CA464: DISTRIBUTED PROGRAMMING 2 Contrast Between SOAP & REST Cont d REST tries to isolate complexity at endpoints (Clients & Service): Service: could need to logic/computation to process XML to maintain Resources & generate their representation. Client: may have to process XML to extract info from XML representation. But this complexity is kept from the transport level. SOAP complicates the transport level as a SOAP message is encapsulated as transport message body. More on Resources Resources have certain properties: Representation: usually MIME (commonly text/html, text/xml). State: i.e. they are mutable. Note: In a RESTful request on a resource, the resource itself stays on the service-side. If the request succeeds, the requester gets the resource s representation (this transfers from the server to the requester machine). For a successful request to read a resource, it s typed representation (e.g. text/html) transfers from the resource s server to the requester. Recall: HTTP (REST) Operations Essence Communication in the Web is generally based on HTTP. Operation Idempotent? Description Head Yes Request to return the header of a document Get Yes Request to return a document to the client Put Yes Request to store a document Post No Provide data that are to be added to a document (collection) Delete Yes Request to delete a document in REST Shown below is a client comms with a resource & the typed responses it gets: GET request could return my biography (html or video). Typical html resource representations could have other resource links. These could then be the target of HTTP requests with appropriate CRUD verbs.

for the resource. Each HTTP request includes a verb to indicate which CRUD operation should be performed on the resource. A good representation is precisely one that matches the requested operation and captures the resource s state in some appropriate way. For example, in this depiction a GET request could return my biography as a hacker as either an HTML document or a short video summary. The video would fail CA464: DISTRIBUTED to capture the PROGRAMMING state of the resource if it depicted, say, only the major disasters in my 3 brother s career rather than those in my own. A typical HTML representation of the resource would include hyperlinks to other resources, which in turn could be the target of HTTP requests with the appropriate CRUD verbs. Identifying URL: http://my.life.job/hacker Resource: My life as a hacker HTTP requests GET: Read POST: Create PUT: Update DELETE: Delete HTTP responses MIME-typed representations of the resource such as: GET: HTML page with my hacker s bio GET: Short video of major disasters PUT: Plain text acknowledgement of update POST: Fancy HTML acknowledgement of resource creation RESTful client Figure 4-1. A small slice of a RESTful system HTTP also has standard response codes, such as 404 to signal that the requested resource could ofnot URIs be found, and 200 to signal that the request was handled successfully. A Subtlety: Opacity In short, HTTP provides request verbs and MIME types for client requests and status A URI is meant codes to be (and opaque MIME types) for service responses. This means Modern thatbrowsers the URI: generate http://bedrock/citizens/fred only GET and POST requests. Moreover, many applications treat these two types of requests interchangeably. For example, Java HttpServlets have has no inherent connection to the URI: http://bedrock/citizens, callback methods such as doget and dopost that handle GET and POST requests, re- Fred happens Each callback to be a has citizen the same of Bedrock. parameter types, HttpServletRequest (the key/ althoughspectively. value pairs from the requester) and HttpServletResponse (a typed response to the requester). It is common to have the two callbacks execute the same code (for instance, A Note of caution by having one invoke the other), thereby conflating the original HTTP distinction between read and create. A key guiding principle of the RESTful style is to respect the Of course, original good meanings designers of the devise HTTP URIs verbs. akin In particular, to whatany they GET identify, request but should URIs be side have no intrinsiceffect-free hierarchical (or, structure. in jargon, idempotent) because a GET is a read rather than a create, update, or delete operation. A GET as a read with no side effects is called a safe GET. URI syntax resembles that for file system navigation, but this can mislead; URIs are opaque identifiers, The REST approach each naming does not exactly imply one that either resource. resources or the processing needed to generate adequate representations of them are simple. A REST-style web service might be every bit as subtle and complicated as a SOAP-based service. The RESTful approach A Ruby Client on a Web Service Using Ruby s Rest Client.gem with CrunchBase REST interface What Is REST? 123 Here we use Rest Client.gem (e.g. with interactive Ruby shell irb). URI is a CrunchBase request given to Rest Client s Get method. If you want, emit the resp.body, (& see all JSON data returned). www.it-ebooks.info You can use the JSON.parse method to parse the response into a Ruby object structure. Finally, extract the desired value ( 'number of employees=50' here). A Ruby Client on a Web Service (cont d) Here, a Ruby Client uses Rest Client.gem to make life easier.

CA464: DISTRIBUTED PROGRAMMING 4 #!/usr/bin/env ruby require 'rest_client' #require 'json' #require 'net/http' // don't need as rest_client.gem has all these // don't need as rest_client.gem has all these class Crunchery @record=nil def initialize (name="ibm") @name=name end end def print_data (company="ibm") // default value is "IBM" base_url="http://api.crunchbase.com" key="6y hw" // my key; you have to get your own company="whatsapp" // the company url="#{base_url}/v/1/company/#{company}.js?api_key=#{key}" puts url // echo url variable to screen resp=restclient.get url // call RestClient.get @record=json.parse(resp) puts @record['number_of_employees'] // output whatsapps roll no. end if FILE == $0 mg = Crunchery.new ("whatsapp") mg.print_data puts "end reached" // Main File to run the above // See output below C:\Ruby193>ruby Crunchery.rb http://api.crunchbase.com/v/1/company/whatsapp.js?api key=6y 50 end reached hw A User Interface Client on a Web Service The RestClient UI Get s Bookmarks from Bibsonomy.com. Note: password is user hash from registration with Bibsonomy.com.

CA464: DISTRIBUTED PROGRAMMING 5 The bookmark results of the previous Get operation. RestClient uses Post to add a Bookmark to Bibsonomy.com. Note: Change content-type to application/xml & charset to UTF-8. Nb! The bookmark results of the previous Post operation.

CA464: DISTRIBUTED PROGRAMMING 6 Success! Take note of hash needed later! RestClient uses Put to change a Bookmark thus http://www.bibsonomy.org/api/users/martycrane/posts/ Use of hash to alter/delete Nb! The bookmark results of the previous Put operation.

CA464: DISTRIBUTED PROGRAMMING 7 Success! New Tag: HypochondriaStuff RestClient uses Delete to remove a Bookmark thus http://www.bibsonomy.org/api/users/martycrane/po Use of hash to alter/delete Nb! The bookmark results of the previous Delete operation.

CA464: DISTRIBUTED PROGRAMMING 8 Success!