Rest & WebApi

Preview:

Citation preview

RESTfulAuthor:

TU TranSkype: tranthanhtu83

Overview

Actions (Verbs)

Output

Constraints

Q&A

Agenda

TU Tran

REST stands for “Representational State Transfer”

Overview

TU Tran

Overview

TU Tran

Web serverClient (Browser)

Request

Response

Hey, I need to GET detail of #4 user

Here it is:

Actions (Verbs)

TU Tran

Get list of resource

Get detail of resource

Create new resource

Update of resource

Delete a resource

Actions/ Get

TU Tran

Actions/ Create

TU Tran

Actions/ Update

TU Tran

Actions/ Delete

TU Tran

Output

TU Tran

-JSON-XML-CSV

Output

TU Tran

- Use header requestAccept: application/json

- Use query stringGet http://localhost/user.json

- Use file extensionGet http://localhost/user.json

Constraints

TU Tran

Client – ServerUniform InterfaceStatelessCacheableLayered SystemCode on Demand (optional)

Constraints / Client - Server

TU Tran

I will show this as the list of users

OK, I will get this from MSSQL

- Get detail of #4 user: ../api/users/4

- Get detail of #2 category: ../api/categories/2

Constraints / Uniform Interface

TU Tran

The request must be independent each other Easy to add more servers if need

Constraints / Stateless

TU Tran

Web serverClient (Browser)

Request

Response

Hey Server, Please looks in the package to get whatever you need

OK, I have all information to process your request

Constraints / Cacheable

TU Tran

Avoiding unnecessary processing Significantly increasing performance

Constraints / Layered System

TU Tran

This structure is much more flexible to change

TU Tran

Q&A

THANK YOU

TU Tran

Recommended