Chengyu Sun California State University, Los Angeles

Slides:



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

Give it a REST already Arnon Rotem-Gal-Oz VP R&D xsights
REST Vs. SOAP.
Introduction to Web Services
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
General introduction to Web services and an implementation example
Building RESTful Interfaces
SOAP.
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
Web Services Nasrullah. Motivation about web service There are number of programms over the internet that need to communicate with other programms over.
06 | Implementing Web APIs Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
Web Services CS Web Services Internet-available services using XML messaging, for computer-computer interaction Not tied to any OS or language Self-describing:
CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web.
RESTful Web Development With Nodejs and Express. REST Stands for REpresentational State Transfer Has the following constraints: ◦Client-Server ◦Stateless.
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Prepared By : Monika Darji Web Services using REST & JAX-WS.
Web Services XML-RPC, SOAP, REST Advanced Web-based Systems | Misbhauddin.
Lecture 15 Introduction to Web Services Web Service Applications.
Python and REST Kevin Hibma. What is REST? Why REST? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a.
Web Services Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
RESTful Web Service 2014 년 12 월 한연희
1 Seminar on Service Oriented Architecture Principles of REST.
Web Services, SOAP, and WSDL CSCI Web Services for B2B communication.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
Advanced Web Technologies Lecture #4 By: Faraz Ahmed.
CSCE 315 – Programming Studio Spring Goal: Reuse and Sharing Many times we would like to reuse the same process or data for different purpose Want.
RESTful Web Services What is RESTful?
Web Services An Introduction Copyright © Curt Hill.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
.NET Mobile Application Development XML Web Services.
Lecture VI: SOAP-based Web Service CS 4593 Cloud-Oriented Big Data and Software Engineering.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
CS520 Web Programming Introduction to Web Services Chengyu Sun California State University, Los Angeles.
National College of Science & Information Technology.
CS3220 Web and Internet Programming RESTful Web Service
CS520 Web Programming Introduction to Web Services
Introduction to Web Services
Tiny http client and server
RESTful Sevices Distributed Objects Presented by: Shivank Malik
Better RESTFul API – Best Practices
CS5220 Advanced Topics in Web Programming Web Services
Sabri Kızanlık Ural Emekçi
WEB SERVICES.
REST- Representational State Transfer Enn Õunapuu
Node.js Express Web Services
Unit – 5 JAVA Web Services
GF and RS, Dept. of CS, Mangalore University
An introduction to REST for SharePoint 2013
Advanced Web-based Systems | Misbhauddin
CMPE 280 Web UI Design and Development October 24 Class Meeting
CHAPTER 3 Architectures for Distributed Systems
Representational State Transfer
Ashish Pandit IT Architect, Middleware & Integration Services
WEB API.
Web services, WSDL, SOAP and UDDI
$, $$, $$$ API testing Edition
Creating a Distributed System with Remote Procedure Calls and Web Services Ch.5 B.Ramamurthy 2/17/2019 B.Ramamurthy.
CS5220 Advanced Topics in Web Programming Web Services
REST APIs Maxwell Furman Department of MIS Fox School of Business
Chengyu Sun California State University, Los Angeles
RESTful Web Services.
WEB SERVICES From Chapter 19, Distributed Systems
Python and REST Kevin Hibma.
CS4961 Software Design Laboratory Understand Aquila Backend
Chengyu Sun California State University, Los Angeles
Week 05 Node.js Week 05
Chengyu Sun California State University, Los Angeles
NEECOM – May 22, 2019 Todd L Gould, CEO
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Chengyu Sun California State University, Los Angeles CS4540 Special Topics in Web Development ASP.NET Core: Design and Implement Web API Chengyu Sun California State University, Los Angeles

Web API A.K.A. RESTful/REST Web Service RESTful/REST Web API REST API

A Brief History of Web Service Remote Procedure Call Simplifies network programming RPC CORBA Cross-platform RPC (Traditional) Web Services Cross-platform RPC over HTTP SOAP – complex and not efficient RESTful Web Services

RPC – Client-Server Interaction as Function Calls Employee e = GetEmployee(1); Automatically translate function calls to network operations Encode and decode parameters and return values Send and receive data between the client and the server Employee GetEmployee(int id) { … return employee; } Server

CORBA Common Object Request Broker Architecture Use Interface Definition Language (IDL) to describe service interface Provide mappings from IDL to other languages such as Java, C++, and so on. Java Service Interface in IDL Service Implementation C++ … Client Server

(Traditional) Web Services RPC over HTTP Client and server communicate using HTTP requests and responses Traditional web service stack SOAP for data exchange WSDL for API description UDDI for web service directories

Problems With Traditional Web Services Very complex Based on some very complex specifications Very difficult to create supporting libraries Virtually impossible to use without supporting libraries Not very efficient (XML is a very verbose language)

Mimic a Web Service Without All the Trouble Traditional Web Service Call GetEmployee(1) Some magic happens Get an Employee object Client Server "New" Web Service Send a request to /Employees/1 Get a response Convert the response to an Employee object Client Server

About "New" Web Services: The Method URL: http://<host>/Employees/{id} Method: GetEmployee(int id) The URL pattern is the method name, and the request parameters are the method parameters, hence the term Web API

About "New" Web Services: The Return Value In "New" Web Service, it's now the client's responsibility to convert the response into an object, which is why the response is usually in JSON and/or XML

About "New" Web Services: The Benefit Now any web application language/technology can be used to create web services, which are basically web applications for programs In particular, it's the same MVC minus V

REST – Make "New" Web Services Better REpresentational State Transfer Introduced by Roy Fielding in his Ph.D. dissertation on network-base software architecture Describes the common characteristics of scalable, maintainable, and efficient distributed software systems

The REST Constraints Client and server Stateless Support caching Uniformly accessible Layered (Optional) support code-on-demand

RESTful Web Services Mimic how the static web (i.e. the largest REST system) works Use URLs that look like URLs for static web pages Utilize request methods and headers Utilize response status codes Stateless, i.e. no session

RESTful Web Service Design Identify resources and operations Determine resource representation, i.e. JSON and/or XML Design the "API" (a.k.a. end points), i.e. URL patterns, request methods/parameters/headers, etc.

Web API Design Conventions Route parameters over query parameters Map request methods to CRUD operations POST GET PUT DELETE Create Retrieve Update Delete

Web API Design Example (I) Operation HTTP Request Get a project GET /projects/1 HTTP 1.1 Delete a project DELETE /projects/1 HTTP 1.1 Update a project PUT /projects/1 HTTP 1.1 { "id": 1, "name": "Firestone2”}

Web API Design Example (II) Operation HTTP Request Get all project GET /projects HTTP 1.1 Add a project POST /projects HTTP 1.1 { "name": "Yellow", "leaderId": 2,} How about adding/removing an employee to/from a project??

Web API Implementation Example Project management Get all projects Get a project by id Add an employee to a project Remove an employee from a project

Example: Get All Projects Controller vs. ControllerBase Attribute Routing vs Conventional Routing Serialization and De-serialization Content negotiation

Attribute Routing vs. Conventional Routing Web API usually use attribute routing because the action is usually expressed in request method rather than the URL Attribute routing takes precedence over conventional routing

Serialization and Deserialization Object XML/JSON De-serialization ASP.NET Core applications use JSON formatter by default Additional formatters can be added with additional packages

Content Negotiation The format of the data is determined by Accept header example: Accept: application/json,text/xml;q=0.9 The format of the data is determined by The accept header The object itself Whether the client is a browser See Chapter 9.6.2 of ASP.NET Core in Action

Example: Get A Project By Id Use of status codes and helper methods in ControllerBase Ok() NotFound()

Example: Add an Employee to a Project Add an object to a many-to-many collection Test Web API using Postman

Example: Remove an Employee from a Project Remove an object from a many-to-many collection Use JavaScript in a web application as Web API client @section jQuery

Web API Clients Web API Server Web Applications Mobile Apps Desktop Other Web Services

Readings ASP.NET Core in Action: Chapter 9