© Donald F. Ferguson, 2014. All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Dr. Donald F. Ferguson.

Slides:



Advertisements
Similar presentations
Pierre-Johan CHARTRE Java EE - JAX-RS - Pierre-Johan CHARTRE
Advertisements

18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
Introduction to Web Services
Web Service Architecture
Siebel Web Services Siebel Web Services March, From
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
SOAP Quang Vinh Pham Simon De Baets Université Libre de Bruxelles1.
Building an Operational Enterprise Architecture and Service Oriented Architecture Best Practices Presented by: Ajay Budhraja Copyright 2006 Ajay Budhraja,
Chapter 3: Programming Web Services Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley, 2005.
1 Introduction to XML. XML eXtensible implies that users define tag content Markup implies it is a coded document Language implies it is a metalanguage.
Distributed components
G O B E Y O N D C O N V E N T I O N WORF: Developing DB2 UDB based Web Services on a Websphere Application Server Kris Van Thillo, ABIS Training & Consulting.
Presentation 7 part 2: SOAP & WSDL. Ingeniørhøjskolen i Århus Slide 2 Outline Building blocks in Web Services SOA SOAP WSDL (UDDI)
Peoplesoft: Building and Consuming Web Services
Software – Part 3 V.T. Raja, Ph.D., Information Management College of Business Oregon State University.
Web Services Michael Smith Alex Feldman. What is a Web Service? A Web service is a message-oriented software system designed to support inter-operable.
Enterprise Resource Planning
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Designing and Implementing Web Data Services in Perl
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 09. Review Introduction to architectural styles Distributed architectures – Client Server Architecture – Multi-tier.
XML Web Services Architecture Siddharth Ruchandani CS 6362 – SW Architecture & Design Summer /11/05.
Chapter 6 Server-side Programming: Java Servlets
Web Services Presented By : Noam Ben Haim. Agenda Introduction What is a web service Basic Architecture Extended Architecture WS Stacks.
Grid Services I - Concepts
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
API Crash Course CWU Startup Club. OUTLINE What is an API? Why are API’s useful? What is HTTP? JSON? XML? What is a RESTful API? How do we consume an.
© Donald F. Ferguson, All rights reserved. Topics in Computer Science: COMS E Micro-service Application and API Development Lecture.
© Donald F. Ferguson, All rights reserved. Topics in Modern Internet Application Development: Project 1a Observations, Message Queuing, REST, Composite.
1 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 2: REST Details and Patterns Some.
Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 2: REST Details and Patterns Some.
© Donald F. Ferguson, All rights reserved. Topics in Modern Internet Application Development: Iteration, REST, Composite Applications, Pub/Sub Dr.
AMQP, Message Broker Babu Ram Dawadi. overview Why MOM architecture? Messaging broker like RabbitMQ in brief RabbitMQ AMQP – What is it ?
RESTful Web Services What is RESTful?
REST By: Vishwanath Vineet.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
© Donald F. Ferguson, All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Dr. Donald F. Ferguson.
1 Service Oriented Architecture SOA. 2 Service Oriented Architecture (SOA) Definition  SOA is an architecture paradigm that is gaining recently a significant.
Copyright © 2004, Keith D Swenson, All Rights Reserved. OASIS Asynchronous Service Access Protocol (ASAP) Tutorial Overview, OASIS ASAP TC May 4, 2004.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
© Donald F. Ferguson, All rights reserved. Topics in Computer Science: COMS E Micro-service Application and API Development Lecture.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
Representational State Transfer COMP6017 Topics on Web Services Dr Nicholas Gibbins –
Software Architecture Patterns (3) Service Oriented & Web Oriented Architecture source: microsoft.
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
A service Oriented Architecture & Web Service Technology.
© Donald F. Ferguson, All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Dr. Donald F. Ferguson.
Sabri Kızanlık Ural Emekçi
WEB SERVICES From Chapter 19 of Distributed Systems Concepts and Design,4th Edition, By G. Coulouris, J. Dollimore and T. Kindberg Published by Addison.
Node.js Express Web Services
The Client/Server Database Environment
Representational State Transfer
Ashish Pandit IT Architect, Middleware & Integration Services
Wsdl.
WEB API.
Inventory of Distributed Computing Concepts and Web services
Lecture 1: Multi-tier Architecture Overview
CSSSPEC6 SOFTWARE DEVELOPMENT WITH QUALITY ASSURANCE
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Distributed Systems through Web Services
Database Management Systems
WEB SERVICES From Chapter 19, Distributed Systems
Remedy Integration Strategy Leverage the power of the industry’s leading service management solution via open APIs February 2018.
TN19-TCI: Integration and API management using TIBCO Cloud™ Integration
Chengyu Sun California State University, Los Angeles
Presentation transcript:

© Donald F. Ferguson, All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Dr. Donald F. Ferguson (Admin:

2 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Contents

3 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Contents Introduction –A little about me. –Course topics and schedule. –Assignments and grading. –Resources. Core Concepts –SOA, Web services, components. –Composite applications. –Examining the phrase “Modern Internet Service Oriented Application.” REST and SOA –Overview –Stateless, Idempotent –What can we learn from a relational datamodel? –Collections, keys, ad hoc query –Projection, partial update –Relationships and associations –Iteration, pagination –Metadata and reflection –Asynchronous operations –Events, notifications First assignment

4 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Introduction

5 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro A Little About Me … Career –Columbia –11 years as a student: B.A., M.S., M.Phil and Ph.D from Columbia University –Ph.D. Thesis – The Application of Microeconomics to the Design of Resource Allocation and Control Algorithms. –Previously taught 4 classes at Columbia –IBM –IBM Research for 10 years; IBM Software Group –Foundational work on web applications, J2EE and Web Services –IBM Fellow and Chief Architect for IBM Software Group –Microsoft –Technical Fellow –Technical strategy for future innovation in enterprise software –Initial work on BizTalk.net, and Integration-Platform-as-a-Service; Some concepts in Azure –CA technologies –Chief architect, Distinguished Engineer and CTO –Technical strategy and product architecture –Dell Software Group –Senior Fellow and CTO –Product architecture and technical strategy –Current focuses are cloud, cloud marketplaces, BYOD, IoT, iPaaS and next generation security Interests –Languages: Speak Spanish well. Learning Arabic slowly. Interested in linguistics and language theory. –Amateur astronomer –Road bicycling –Martial arts: Black belt in Kenpo karate; Krav Maga

6 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Tentative Course Schedule

7 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Assignments and Grading Grading –Grading will be based on –5, equally weighted, standalone team projects –5-6 page architecture/design paper. –Code review. –Demo. –You will provide a contribution percentage for each team member. –Class participation –Teams –Please form 4-5 person teams and let me know the members. –Send me an if you cannot find a team, and I will form some teams. –You may change team membership between projects. –I will take team size into consideration when assessing. We will not have a midterm or final.

8 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Resources Unfortunately, there is no textbook(s) –Books tend to be out of date. –The course is surveying multiple topics, which would require many books. –The web tends to be the best source of documents and tutorials. Some books –I will be using parts of SOA Patterns by A. Rotem-Gal-Oz ( ) for some early parts of the course. –The classics are –“Patterns of Enterprise Application Architecture” by Martin Fowler. –“Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions” by Holpe and Wolf. –“SOA Design Patterns” by Thomas Erl. – is a good, broad, shallow overview. –The best programmer I have ever known, and someone who mentors new programmers, recommended “Domain- driven Design: Tackling Complexity in the Heart of Software” by Eric Evans. I have not read this book.

9 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Core Concepts

10 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro SOA DEFINITION Service-oriented architecture (SOA) is an architectural style for build­ing systems based on interactions of loosely coupled, coarse-grained, and autonomous components called services. Each service exposes processes and behavior through contracts, which are composed of messages at discoverable addresses called endpoints. A service’s behavior is governed by policies that are external to the service itself. The contracts and messages are used by external components called service consumers. Some observations – SOA is a reaction to distributed OO and RPC. –Coarse Grained and Messages –OO tends to lots of small classes/objects and fine-grain API calls (e.g. person.getIq()). –SOA tends to person.getState(). –Loosely coupled –Assume API calls “go remote” but may have local optimization. –Interfaces (Contracts) are not strongly typed, enabling independent evolution. –Endpoints –OO assumes “Java calling Java, perhaps over RMI.” –SOA separate Contract from Binding (WS-Interop, REST, message queues, etc). –Discoverable –OO assumes a classpath, findByClassName() and perhaps factory patterns. –SOA assumes you can go to a web callable repository and ask for SOA endpoints based on Contracts/Messages. –Web Services are a set of standards for SOA that enable interoperability.

11 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro SOA Various developer tools generate helper classes, allowing the programmer to focus on application logic and not details of formatting XML messages for SOAP. Services often go into containers that automate implementation of policies, e.g. transactions, security, reliable messaging.

12 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Composite Applications – Some Definitions “In computing, a composite application is a software application built by combining multiple existing functions into a new application. … A composite application consists of functionality drawn from several different sources. The components may be individual selected functions from within other applications, or entire systems whose outputs have been packaged as business functions, modules, or web services.” ( “Composition refers to a way of delivering enterprise solutions by assembling them from prebuilt components, instead of building them from scratch. It also includes personalization and customization abilities, so that users can easily and quickly modify specific functionality in the solution.” ( us/library/bb aspx) us/library/bb aspx “A composite application orchestrates independently developed programs, data and devices to deliver a new solution that none of the previously available applications could deliver on its own. Each resource accessed by a composite application uses a different data model. In most cases, the composite application supports user interactions beyond those provided by the leveraged applications. In other cases, a composite application may act as a service. Some composite applications are built by leveraging other composite applications.” (

13 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Composite Applications – Some Pictures

14 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Composites Start with Components

15 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Flexible Implementation – Some of which we will Cover

16 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro A Container: Application Server Architecture JNDI Sort of like DNS, but for APIs. Look up a provider of an API by a human name Resource Links The things I look up in JNDI. Configurable Instantiated connections JDBC JMS …

17 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Parsing the Course Title Modern Internet Service Oriented Application Development SOA –The same principles apply. –Evolving –From “coarse grained” meaning “big” to a lot of micro-services –Implemented using polyglot programming and persistence –Running in multiple, network addressable processes –That import the middleware functions they need versus being in containers. Internet –More natural usage of the Internet, e.g. –REST versus WSDL/SOAP –Google versus UDDI –Default web apps for API discovery versus WSDL. –And most of the business APIs and infrastructure APIs are “on the web.”

18 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Evolution Cart Functions Java SQLite Recommendation Functions Node.js Redis Catalog Functions PDP MongoDB XXX MMM NNN Content Functions Ruby Amazon S3

19 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Now – Much of what you need is “ on the web ”

20 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Now – Much of what you need is “ on the web ”

21 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro So, What are we going to study Technology for implementing services, e.g. –REST. –Various databases. –Web callable infrastructure, e.g. security, workflow. –Web callable business APIs. –Web/cloud friendly packaging and deployment, e.g. Docker. And “patterns” for “good implementation” –Implement basic services. –Assembly into composites. Weinberg's Second Law: If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization.

22 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Example: Service Implementation Patterns

23 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Example: Service Composition Patterns

24 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro REST and SOA

25 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro REST Overview

26 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Representational State Transfer (REST) People confuse –Various forms of RPC/messaging over HTTP –With REST REST has six core tenets –Client/server –Stateless –Caching –Uniform Interface –Layered System –Code on Demand

27 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro REST Tenets Client/Server (Obvious) Stateless is a bit confusing –The server/service maintains resource state, e.g. Customer and Agent info. –The conversation is stateless. The client provides all conversation state needed for an API invocation. For example, –customerCursor.next(10) requires the server to remember the client’s position in the iteration through the set. –A stateless call is customerCollection.next(“Bob”, 10). Basically, the client passes the cursor position to the server. Caching –The web has significant caching (in browser, CDNs, …) –The resource provider must –Consider caching policies in application design. –Explicitly set control fields to tell clients and intermediaries what to cache/when.

28 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro REST Tenets Uniform Interface –Identify/locate resources using URIs/URLs –A fixed set of “methods” on resources –myResource.deposit(21.13) is not allowed –The calls are –Get –Post –Put –Delete –Self-defining MIME types (Text, JSON, XML, …) –Default web application for using the API –URL/URI for relationship/association Layered System: Client cannot tell if connected to the server or an intermediary performing value added functions, e.g. –Load balancing –Security –Idempotency Code on Demand (optional): Resource Get can deliver helper code, e.g. –JavaScript –Applets

29 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro SSOL Page

30 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Anatomy of a URL SSOL for the Classlist bin/ssol/DhbtiwfsFOMOeFQaDwqxAh/?p%.5Fr%.5Fid=k0F2vZ4ccAhzbcAg0Ql K4h&p%.5Ft%.5Fid=1&tran%.5B1%.5D%.5Fentry=student&tran%.5B1%.5D%. 5Fterm%.5Fid=20143&tran%.5B1%.5D%.5Fcid=COMSE6998&tran%.5B1%.5 D%.5Fsecid=005&tran%.5B1%.5D%.5Fsch=&tran%.5B1%.5D%.5Fdpt=&tran %.5B1%.5D%.5Fback=&tran%.5B1%.5D%.5Ftran%.5Fname=scrs This is –Not REST –This is some form of Hogwarts spell –This is even bad for a web page

31 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Anatomy of a URL “server” containerHTTP:// …/ssol/…The module/component …/listManagerThe Application Object or …/Class/COMSE Entity Class (“Extent”) and ID.../WaitingList/…Contained Resource GET, POST, … on URLfor CRUD Some details –…/WaitlingList/dff9/IQPath navigation into resources –…/WaitlingList?op=“Approve”?CUID=“dff9”Method

32 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro What can we Learn from Data

33 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Database Model are Complex, even examples and samples, e.g. MySql Sakila Sample Database

34 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Some Concepts Foreign key relationships –Represent 1-1, 1-N relationships –Have “behavior,” e.g. –On Delete would prevent deleting a country if there is a city whose country_id is the country’s id. –On Cascade would automatically update all city.country_id when country.id changes Defining indices is important to avoid –Scanning the entire city table to –To find cities in a given country I would not put strings in a table for most words and string –Putting “Spain” for a country name –Prevents localization and national language enablement –Use symbols into localization resource bundles

35 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Views and Stored Procedures

36 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro What can we Learn? The implementation of the SOA contract/REST interface –Is a set of verbs on URLs –That manipulate a logical data model. Every logical data model has a common set of concepts that materialize through REST –ID  URI/URL –Collections supporting –Primary key  …/Customers/21 –Non-unique, secondary keys  …/Customers/Zipcode/12345 –Ad hoc query (SELECT WHERE (… …))  …/Customers?q=“id<=50&lastname=Ferguson” –Projection –SELECT iq, lastname FROM Customers  …/Customers?”Fields=iq,lastname” –UPDATE iq, shoessize WHERE …  PUT {{iq, “50},{…}}  …/Customers –Foreign keys/join tables  Hyperlinks –Iterators –SELECT * FROM Customers CREATE Cursor …  –GET …/Customers?Offset=40&Pagesize=20 –Thread/callback/promise  Asynchronous REST responses –Metadata/reflection: SQL DESCRIBE TABLE  Web UI for driving the REST API –Stored procedures  PUT…/Commands/… –Events/Notifcations  Feeds

37 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Asynchronous Operation

38 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Implementation Observations Define a collection /QueuedResponses –A client can call …/QueuedResponses/21 to get a specific response. –You already know how to do this for …/Customer –The data format in the table is {id, status, JSONString} A simple implementation would be writing a façade –Accept request –Create new table entry with status = “in progress” –Return 202 and URL –Call the actual implementation –Update the database table entry with the JSON result Most application platforms have middleware approaches to support registering callbacks, threads, etc. The implementation would typically –Invoke some long running action, e.g. DB query, workflow process and register a callback –The callback implementation updates the entry in the response table.

39 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Ad Hoc Query Every collection should support ?q=“… …” –…/Customers?q=“lastName=21&IQ<21” –q is a string encoding a set of triplets with elements –Resource field, e.g. “lastName” –Comparison operation, e.g. “=“, “>”, … –Comparison value. Your code needs to –Parse and validate the query string. –Rewrite the string in the query language of the underlying database, e.g. Where clause in SQL –Execute the query –Refine the result set if the underlying database does not support query capabilities that you are surfacing through your API.

40 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Pagination {“data”: [{“user_id”:”42”, “name”:”Bob”, “links”:[{“rel”:”self”, “href”:” {“user_id”:”22”, “name”:”Frank”, “links”: [{“rel”:”self”, “href”:” {“user_id”:”125”, “name”: “Sally”, “links”:[{“rel”:”self”, “href”:” “links”: [{“rel”:“first”, “href”:” {“rel”:“last”, “href”:” {“rel”:“previous”, “href”:” {“rel”:”next”, “href”:”

41 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Implementation Considerations Query rewrite –…/Customers?q=“lastname=Ferguson&id<5”&limit=10&offset=5 –Neatly translates into an SQL statement –Select * from customers where … limit=5 offset=5 Other databases have similar concepts. You may have to –Rewrite a push the query down –Build a result cache in another store that supports limit/offset –Paginate through the cache You should also consider adding –“field=lastname,IQ,color” –To enable selecting a subset of fields

42 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Some Complex Topics

43 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Example Considerations Service Endpoint –Endpoint –Endpoint Encryption Requests and Authentication –Request Headers –Request Timestamps –Request Authentication –Response Headers Resources –Resource Requests –Resource Representation –Resource Methods –Synchronous Operations –Asynchronous Operations –Success Response Codes –Failure Response Codes Resource Data Types –Atomic Types –Complex Type - Object or Structure –Resource Relationships –Resource References Pagination –Through HTTP Link Header –Syntax and Example of Pagination Link Header –Consistency Across Page Requests Versioning –Version Header –Version URI Saying “REST is not enough You have to define a set of patterns/ conventions of URLs, headers, …

44 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Endpoint /a/b/c?x=7&y=21 is a pretty straightforward concept, but … –How do I get info about customer “Ferguson?” –…/Customer/Ferguson/Donald –…/Customer?lastName=“Ferguson”&firstName=“Donald” –??? –Do I really want to –Find info about Don using …/Customer/Ferguson/Donald –Find info about agent using …/Agents?id=“21” –How does it work if I can find customer by name or phone number? –How do I set a relationship between customer and agent? –PUT …/Relationship/AgentFor?agent=“21”&”Customer=“Ferguson” –Or two PUTS, one on Customer and one on Agent? In the same way you have to define a framework for your application, you have to define a shape/pattern in your REST API model.

45 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Headers – Some Choices I Made HTTP Request HeaderValueMandatory auth-timestamp:The current POSIX time.Yes auth-key: The user or client’s unique API KEY. Yes auth-signature: The HMAC-SHA256 digest for the request. Yes api-version:(Optional) API version stringNo Accept: (Optional) application/xml or application/json No Nonce:One time UUID to enable idempotency/duplicate detection

46 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Response Codes OperationHTTP RequestHTTP Response Codes Supported READGET OK with message body OK no message body OK with partial message body CREATEPOST Resource created (Operation Complete) Resource accepted (Operation Pending) UPDATEPUT Accepted (Operation Pending) Success (Operation Complete) DELETE Accepted (Operation Pending) Success (Operation Complete) Examples of Link Headers in HTTP response: Link: ;rel=monitor;title="update profile" Link: ;rel=summary;title=”access report” 202 means Your request went asynch. The HTTP header Link is where to poll for rsp.

47 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Failure Response Code ErrorResponse Code Invalid Parameter400 - Invalid parameter Authentication401 - Authentication failure Permission Denied403 - Permission denied Not Found404 - Resource not found Invalid Request Method405 - Invalid request method Internal Server Error500 - Internal Server Error Service Unavailable503 - Service Unavailable

48 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Design Pattern Choices Resource Requests Collectionhttps://ENDPOINT/NAMESPACE/RESOURCE[?QUERY_PARAMETERS] Resourcehttps://ENDPOINT/NAMESPACE/RESOURCE/RESOURCE_ID[?QUERY_PARAMETERS] Collection OperationHTTP Request Get all items in the collection GET /collection Should also return the URI of the collection itself. Get an particular item in the collectionGET /collection/itemId Get items match certain criteriaGET /collection?property1=’value’ Add a new item to the collection POST /collection contents of new item … Get items starting at 100 with page size=25 GET /collection?start=100&pageSize=25 Support for Map Array Collection

49 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Relationships {“membership”: { “URI” : “ “created” : “ T12:00:00.0Z”, “owner” : “user123456”, “expire” : “never”, “group” : { “ref” : “ }, “server” : { “ref” : “ } "link": { "href": " "rel": "self", “title” : “server-s123456” } Relationship as a resource Relationship as a field in resource

50 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Navigating Through Result Set GET on collections, maps, … needs pagination and cursors –Limit: What is the maximum number of elements you want? –QueryID: A tag for the query that produced the original result set –Offset references a specific element in a “page.” There is a standard for linking resources in logical sets, e.g. –Link: ; rel="previous"; title="previous chapter“> –Indicates that "chapter2" is previous to this resource in a logical navigation path. Your API/framework can use this for result sets –Example 1 –GET /api/customers?status=“Gold” returns some number of “Gold” customers and –Link Header for “next page” is Link: ; rel="next last“ –Which is the URL for the “cursor.next set,” which has 50 elements and is also “last” –Example 2 –Get returns the “next” from example 1 –With Link Link: ; rel="prev first" –Allowing you to go backwards to the previous “page.”

51 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro What ’ s Next?

52 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Next Steps The first project will be (assign next week) –Implementing a well-designed REST API, e.g. –Sensible use of URLs and verbs –Handling links properly –Pagination –Partial get/update –Encapsulating a simple, but complex enough data model, e.g. –Primary keys, secondary keys –Foreign keys –Relational integrity semantics The next step for you is to –Set up a development/runtime environment, e.g. –LAMP –node.js –Play around with surfacing REST APIs and connecting to a database. We will start examining more complex topics once we can build a “component.”

53 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Backup

54 © Donald F. Ferguson, All rights reserved.Modern Internet Service Oriented Application Development – Lecture 1: Introduction, Core Concepts, REST Intro Views