REST Easy with Infrared360

Similar documents
Services Web Nabil Abdennadher

REST A brief introduction

RESTful Services. Distributed Enabling Platform

04 Webservices. Web APIs REST Coulouris. Roy Fielding, Aphrodite, chp.9. Chp 5/6

ReST 2000 Roy Fielding W3C

WWW, REST, and Web Services

INF5750. RESTful Web Services

Develop Mobile Front Ends Using Mobile Application Framework A - 2

The HTTP protocol. Fulvio Corno, Dario Bonino. 08/10/09 http 1

Towards a more RESTful world. Anurup Joseph Elegan Consulting

RESTFUL WEB SERVICES - INTERVIEW QUESTIONS

Service Oriented Architectures (ENCS 691K Chapter 2)

Introduction to REST. Kenneth M. Anderson University of Colorado, Boulder CSCI 7818 Lecture 6 08/27/2008. University of Colorado 2008

Copyright 2014 Blue Net Corporation. All rights reserved

REST Web Services Objektumorientált szoftvertervezés Object-oriented software design

Other architectures are externally built or expanded

CSCI-1680 WWW Rodrigo Fonseca

CSCI-1680 WWW Rodrigo Fonseca

Web Services Week 10

Black Box DCX3000 / DCX1000 Using the API

HTTP, REST Web Services

Understanding RESTful APIs and documenting them with Swagger. Presented by: Tanya Perelmuter Date: 06/18/2018

Application Protocols and HTTP

REST AND AJAX. Introduction. Module 13

Controller/server communication

HTTP (HyperText Transfer Protocol)

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

CS 43: Computer Networks. Layering & HTTP September 7, 2018

Send me up to 5 good questions in your opinion, I ll use top ones Via direct message at slack. Can be a group effort. Try to add some explanation.

Application Layer Introduction; HTTP; FTP

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

Discussion #4 CSS VS XSLT. Multiple stylesheet types with cascading priorities. One stylesheet type

AIM Enterprise Platform Software IBM z/transaction Processing Facility Enterprise Edition 1.1.0

KTH ROYAL INSTITUTE OF TECHNOLOGY. Remote Invocation. Vladimir Vlassov and Johan Montelius

A short introduction to Web Services

Introduc)on to Computer Networks

REST API s in a CA Plex context. API Design and Integration into CA Plex landscape

Designing RESTful Web Applications. Ben Ramsey

Oracle RESTful Services A Primer for Database Administrators

REST. Lecture BigData Analytics. Julian M. Kunkel. University of Hamburg / German Climate Computing Center (DKRZ)

STANDARD REST API FOR

Controller/server communication

Kim Dalsgaard. Co-owner of, and Software Designer at Trifork Athene Co-founder of Aarhus Ruby Brigade

SRIJAN MANANDHAR MQTT BASED COMMUNICATION IN IOT. Master of Science thesis

Cloud Computing Chapter 2

REST. And now for something completely different. Mike amundsen.com

Web Technology. COMP476 Networked Computer Systems. Hypertext and Hypermedia. Document Representation. Client-Server Paradigm.

Web-APIs. Examples Consumer Technology Cross-Domain communication Provider Technology

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

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

INFO/CS 4302 Web Informa6on Systems

pages Jason Chambers AJUG February 2005

Lesson 15 SOA with REST (Part II)

Architectural patterns and models for implementing CSPA

The Architecture of the World Wide Web

Application Design and Development: October 30

Unraveling the Mysteries of J2EE Web Application Communications

Scalable Microservice Based Architecture For Enabling DMTF Profiles

SOA & REST. Ola Angelsmark

The Architecture of the World Wide Web

Composer Help. Web Request Common Block

Lesson 14 SOA with REST (Part I)

Web Architecture and Technologies

How A Website Works. - Shobha

Power to the People! Web Service Scoring for the Masses

A RESTful Approach to the Management of Cloud Infrastructure. Swit Phuvipadawat Murata Laboratory

RESTful Web Services. 20-Jan Gordon Dickens Chariot Solutions

WEB TECHNOLOGIES CHAPTER 1

RESTful API Design APIs your consumers will love

Distributed Systems. Web Services (WS) and Service Oriented Architectures (SOA) László Böszörményi Distributed Systems Web Services - 1

RESTful Web services

Webspeed. I am back. Enhanced WebSpeed

Introduction to RESTful Web Services. Presented by Steve Ives

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary

Semantic Web Lecture Part 1. Prof. Do van Thanh

Il Mainframe e il paradigma dell enterprise mobility. Carlo Ferrarini zsystems Hybrid Cloud

INFOH-511 WEB SERVICES. LECTURE 1: Introduction

Zero Latency HTTP The comet Technique

HTTP Protocol and Server-Side Basics

Scalable applications with HTTP

describe the functions of Windows Communication Foundation describe the features of the Windows Workflow Foundation solution

Simple Object Access Protocol (SOAP) Reference: 1. Web Services, Gustavo Alonso et. al., Springer

Etanova Enterprise Solutions

Yioop Full Historical Indexing In Cache Navigation. Akshat Kukreti

COMPUTER NETWORKS AND COMMUNICATION PROTOCOLS. Web Access: HTTP Mehmet KORKMAZ

Chapter 10 Web-based Information Systems

Internet Connectivity with

REST: I don't Think it Means What You Think it Does. Stefan

Developing RESTful Services Using JAX-RS

Introduction to REST Web Services

Computer Networks. Wenzhong Li. Nanjing University

ICS 351: Today's plan. IPv6 routing protocols (summary) HTML HTTP web scripting languages certificates (review) cookies

Protocol Buffers, grpc

RESTful Service Composition with JOpera

HTTP, circa HTTP protocol. GET /foo/bar.html HTTP/1.1. Sviluppo App Web 2015/ Intro 3/3/2016. Marco Tarini, Uninsubria 1

Application Layer: The Web and HTTP Sec 2.2 Prof Lina Battestilli Fall 2017

Network Applications and the Web

FIREFLY ARCHITECTURE: CO-BROWSING AT SCALE FOR THE ENTERPRISE

There is REST and then there is REST. Radovan Semančík November 2017

Apache Wink Developer Guide. Draft Version. (This document is still under construction)

Transcription:

REST Easy with Infrared360 A discussion on HTTP-based RESTful Web Services and how to use them in Infrared360

What is REST? REST stands for Representational State Transfer, which is an architectural style for networked hypermedia applications, Today REST is primarily used to build Web services that are lightweight, maintainable, and scalable. A service based on REST is called a RESTful service. REST is not dependent on any protocol, but almost every RESTful service uses HTTP as its underlying protocol. Other kinds of web services, such as SOAP web services, expose their own arbitrary sets of operations.

History of REST REST was first coined by computer scientist Roy Fielding in his year-2000 Ph.D. dissertation at the University of California, titled Architectural Styles and the Design of Network-based Software Architectures. SOAP Web Services started back in 1998 at Microsoft "Representational State Transfer (REST)," described Fielding's beliefs about how best to architect distributed hypermedia systems. Fielding noted a number of boundary conditions that describe how REST-based systems should behave. These conditions are referred to as REST constraints, with four of the key constraints described below: Use of a uniform interface (UI). Resources in REST-based systems should be uniquely identifiable through a single URL, and only by using the underlying methods of the network protocol, such as DELETE, PUT and GET with HTTP, should it be possible to manipulate a resource.

History of REST (Continued) Client-server-based. In a REST-based system, there should be a clear delineation between the client and the server. UI and request-generating concerns are the domain of the client. Meanwhile, data access, workload management and security are the domain of the server. This separation allows loose coupling between the client and the server, and each can be developed and enhanced independent of the other. Stateless operations. All client-server operations should be stateless, and any state management that is required should happen on the client, not the server. RESTful resource caching. The ability to cache resources between client invocations is a priority in order to reduce latency and improve performance. As a result, all resources should allow caching unless an explicit indication is made that it is not possible.

REST URL formatting Protocol://ServiceName/ResourceType/ResourceID http://myservice/users/1 REST is popular due to its simplicity and the fact that it builds upon existing systems and features of the internet's HTTP in order to achieve its objectives, as opposed to creating new standards, frameworks and technologies. REST-based interactions all communicate their status using standard HTTP status codes. So, a 404 means a requested resource wasn't found; a 401 code means the request wasn't authorized; a 200 code means everything is OK; and a 500 means there was an unrecoverable application error on the server. Similarly, details such as encryption and data transport integrity are solved not by adding new frameworks or technologies, but instead by relying on well-known Secure Sockets Layer (SSL) encryption and Transport Layer Security (TLS). The entire REST architecture is built upon concepts with which most developers are already familiar.

HTTP Client / Server (http://myservice/users/1) Server Client (Internet Browser) HTTP Request (GET) / Response User-N User(1)

JSON vs XML data payload format comparison JSON format example { "ID": "1", "Name": "R Sordillo", "Email": "rs@avada.com", "Country": "US" } XML format example <User> <ID>1</ID> <Name>R Sordillo</Name> <Email>rs@avada.com</Email> <Country>US</Country> </User>

HTTP Request format <VERB> is one of the HTTP methods like: GET, PUT, POST, DELETE, OPTIONS, etc. <URI> is the URI of the resource on which the operation is going to be performed <HTTP Version> is the version of HTTP, generally "HTTP v1.1". <Request Header> contains the metadata as a collection of key-value pairs of headers and their values. These settings contain information about the message and its sender like client type, the formats client supports, format type of the message body, cache settings for the response, and a lot more information. <Request Body> is the actual message content. In a RESTful service, that's where the representations of resources sit in a message. There are no tags or markups to denote the beginning or end of a section in an HTML message.

HTTP POST and GET Request examples POST http://myservice/user/1 Host: MyService Content-Type: application/json; charset=utf-8 Content-Length: 123 { "ID": "1", "Name": "R Sordillo", GET http://www.w3.org/protocols/rfc2616/rfc26 16.html HTTP/1.1 Host: MyService Accept: application/json; charset=utf-8 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-us,en;q=0.8,hi;q=0.6 "Email": "rs@avada.com", "Country": "US" }

HTTP Response HTTP/1.1 200 OK Date: Sat, 23 Sep 2018 18:31:04 GMT Server: Apache/2 Last-Modified: Wed, 01 Sep 2018 13:24:52 GMT Accept-Ranges: bytes Content-Length: 32859 Cache-Control: max-age=21600, must-revalidate Expires: Sun, 24 Sep 2018 00:31:04 GMT Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns='http://www.w3.org/1999/xhtml'> <head><title>hypertext Transfer Protocol -- HTTP/1.1</title></head> <body>...

Difference between PUT and POST The key difference between PUT and POST is that PUT is idempotent while POST is not. No matter how many times you send a PUT request, the results will be same. POST is not an idempotent method. Making a POST multiple times may result in multiple resources getting created on the server. Another difference is that, with PUT, you must always specify the complete URI of the resource. This implies that the client should be able to construct the URI of a resource even if it does not yet exist on the server. This is possible when it is the client's job to choose a unique name or ID for the resource, just like creating a user on the server requires the client to choose a user ID. If a client is not able to guess the complete URI of the resource, then you have no option but to use POST.

Difference between PUT and POST (continued) It is clear from the above table that a PUT request will not modify or create more than one resource no matter how many times it is fired (if the URI is same). There is no difference between PUT and POST if the resource already exists, both update the existing resource. The third request (POST http://myservice/persons/) will create a resource each time it is fired. A lot of developers think that REST does not allow POST to be used for update operation; however, REST imposes no such restrictions.

Caching Cache-Control Directives Caching is the concept of storing the generated results and using the stored results instead of generating them repeatedly if the same request arrives in the near future. This can be done on the client, the server, or on any other component between them, such as a proxy server. Caching is a great way of enhancing the service performance, but if not managed properly, it can result in client being served stale results. Date - Date and time when this representation was generated Last Modified - Date and time when the server last modified this representation. Cache-Control - The HTTP 1.1 header used to control caching Expires - Expiration date and time for this representation. To support HTTP 1.0 clients. Age - Duration passed in seconds since this was fetched from the server. Can be inserted by an intermediary component.

REST requirements REST requires each resource to have at least one URI. A RESTful service uses a directory hierarchy like human readable URIs to address its resources. The job of a URI is to identify a resource or a collection of resources. The actual operation is determined by an HTTP verb. The URI should not say anything about the operation or action. This enables us to call the same URI with different HTTP verbs to perform different operations.

Advantages of using REST REST is language-independent architectural style. REST-based applications can be written using any language, be it Java, Kotlin,.NET, AngularJS or JavaScript. As long as a programming language can make web-based requests using HTTP, it is possible for that language to be used to invoke a RESTful API or web service. Similarly, RESTful web services can be written using any language, so developers tasked with implementing such services can choose technologies that work best for their situation. The other benefit of using REST is its pervasiveness. On the server side, there are a variety of REST-based frameworks for helping developers create RESTful web services, including RESTlet and Apache CXF. From the client side, all of the new JavaScript frameworks, such as JQuery, Node.js, Angular and EmberJS, all have standard libraries built into their APIs that make invoking RESTful web services and consuming the XML- or JSON-based data they return a relatively straightforward endeavor.

Disadvantages of using REST The benefit of REST using HTTP constructs also creates restrictions, however. Many of the limitations of HTTP likewise turn into shortcomings of the REST architectural style. For example, HTTP does not store state-based information between request-response cycles, which means REST-based applications must be stateless and any state management tasks must be performed by the client. HTTP doesn't have any mechanism to send push notifications from the server to the client, it is difficult to implement any type of services where the server updates the client without the use of client-side polling of the server or some other type of web hook. From an implementation standpoint, a common problem with REST is the fact that developers disagree with exactly what it means to be REST-based. Some software developers incorrectly consider anything that isn't SOAP-based to be RESTful. Driving this common misconception about REST is the fact that it is an architectural style, so there is no reference implementation or definitive standard that will confirm whether a given design is RESTful. As a result, there is discourse as to whether a given API conforms to REST-based principles.

REST Alternatives Alternate technologies for creating SOA-based systems or creating APIs for invoking remote microservices include XML over HTTP (XML-RPC), CORBA, RMI over IIOP and the Simple Object Access Protocol (SOAP). Each technology has its own set of benefits and drawbacks, but the compelling feature of REST that sets it apart is the fact that, rather than asking a developer to work with a set of custom protocols or to create a special data format for exchanging messages between a client and a server, REST insists the best way to implement a network-based web service is to simply use the basic construct of the network protocol itself, which in the case of the internet is HTTP. This is an important point, as REST is not intended to apply just to the internet; rather, its principles are intended to apply to all protocols, including WEBDAV, FTP and so on.

Summary REST is another tool in your tool belt. Most vendors, integrators, and companies are providing REST interfaces to their products and solutions. This is due to the low cost of development and ownership. REST might not be the only Web Service technology that you will use. SOAP is still relevant in today's environments, but REST appears to be the future, Cloud and microservices are adopting the RESTFUL web services route..

Avada Infrared360 DEMO Administration REST Interface SWAGGER - REST documentation interface URL Service using REST concepts to perform GET, PUT, DELETE HTTP verbs. Custom Services that you can use to make your own custom REST code Internet Browser Developer Tools (F12)