• 검색 결과가 없습니다.

08.RESTful Web Service

N/A
N/A
Protected

Academic year: 2021

Share "08.RESTful Web Service"

Copied!
9
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Chapter Chapter 신한대학교 2015 봄학기 클라이언트/서버 프로그래밍 고덕윤 [email protected] .

RESTful Web Service

더 나은 웹의 세상으로.

(2)

API

• Application Programming Interface

• 라이브러리가 제공하는 기능을 쓸 수 있게 만든 인터페이스.

01

println(“Hello World”); System.println(String) 화면에 인자를 출력하는 코드 API 호출

(3)

Web 에서도 API를 써보자

• 웹 기반 애플리케이션에서 서비스를 제공하기 위한 명세

• 버스 도착 알림 API

• 구글 지도 API

02

해당지역의 날씨를 제공해주는 서비스 Web API 모바일 클라이언트 웹 클라이언트 모바일 웹 클라이언트 웨어러블 클라이언트 기타 IoT 클라이언트 요청 응답

(4)

Servlet의 Web API

• Servlet 으로 학생정보 관리 url을 만들면

• 쓰기/읽기/수정/삭제(CRUD) 당 각각 하나의 servlet을 제작

• web.xml에 각 servlet에 관한 url을 매핑

• 인자(parameter)가 필요하면 별도의 url을 제작

• http://hostname/service/update.jsp?model=A&id=100

• 이렇게 된다면 얼마나 좋을까?

• 하나의 서블릿 안에서 CRUD를 모두 정의할 수 있다면?

• 호출 url로 간단히 인자를 보낼 수 있다면

• DELETE http://hostname/service/A/100/

• 클라이언트의 객체를 한꺼번에 보낼 수 있다면?

• Student s = new Student(이름,학번,……)

• PUT http://xxx.com/student/s

• 다른 사람도 쓸 수 있는 web api로 서비스를 해보자(open API)

(5)

REST란 무엇인가?

• Representational State Transfer : 표현 가능한 상태 전송

• URI기반으로 자원에 접근하는 기술

• Resource 자체가 URI로 접근

• URI의 구성

• 문서/디렉토리/컨트롤러/파라메터

• 일반적 servlet의 get/post와는 다른 의미로 사용함

• GET : 조회(read)

• POST : 생성(create)

• PUT : 교체(update)

• DELETE : 삭제(delete)

04

(6)

REST 사용 예

05

@Path("/UserAccount")

public class UserAccountService {

}

@POST

public Response createUser(UserAccount account)

{…} @GET

@Path("/{accountKey}")

public UserAccount getUserAccount(@PathParam("accountKey") String accountKey)

{…} @PUT

public Response updateUserAccount(UserAccount inputAccount)

{…} @DELETE

@Path("/{accountKey}")

public Response deleteUserAccount(@PathParam("accountKey") String accountKey)

{…}

POST http://xxx.appsspot.com/UserAccount

GET http://xxx.appsspot.com/UserAccount/12345

PUT http://xxx.appsspot.com/UserAccount

(7)

JSON의 사용

• JavaScript Object Notation

• 경량형 DATA 교환방식

• XML의 무거운 부가정보의 한계를 극복하기 위해 등장

• REST에서 객체를 주고 받는데 사용

(8)

JSON사용의 예

07

[JAVA Object] key : 1535 account:[email protected] nicName:Batman password:P@ssw0rd {“account”:”[email protected]”, “nicName”:”Batman”, “Password”:”P@ssw0rd”} Object to JSON [C# Object] key : 1535 account:[email protected] nicName:Batman password:P@ssw0rd JSON to Object

[Servlet JAVA Object] key : 1535 account:[email protected] nicName:Batman password:P@ssw0rd JSON Obj. Obj.

(9)

실습

• 실습은 다음시간에…

참조

관련 문서

웹 방화벽(Web Application Firewall, WAF)은 홈페이지 서비스를 위한 전용 보안 솔루션으로 SQL 인젝션, XSS 등과 같은 웹 공격을 탐지하고 차단할 수 있다.

실제 백종원 대표가 체험을 하는 과정에서 문제가 발견될 경우 바로바로 지적을 하고, 그 모습을 식당 사장님들은 본부에서 모니터 화면을 통해 보기 때문에

또한 공공 데이터포털에서 제공하는 다양한 오픈 API 데이터를 이용하여 우리 생활에서 활용할 수 있는 방법을, 디자인 씽킹 과정을 통해 창의적인 설계를 할

Colorzip 회원 가입... Web

호출 URL 형식..

data mining - process of applying machine learning, visualization, statistical analysis. knowledge discovery & construction - evaluation & interpretation of the extracted

이러한 연구의 초점을 바탕으로 유비쿼터스 컴퓨팅 환경에서 사용자의 상황 에 따라 유연한 서비스를 제공하기 위하여 헬스케어를 위한 상황인식기반 스마

For that purpose, the investigator analyzed the cases of web animation coding algorithm web applicat ions that were the most familiar to designers and set