Web Service VS Web Application | ต่างกันอย่างไร???

Boon Worayut Aksornukul
1 min readOct 18, 2023

--

Web Service และ Web Application ต่างกันยังไง???

ในโลกของ Internet จะมี 2 keywords ที่อาจจะทำให้สับสนได้ นั้นคือ Web Service และ Web Application

โดยส่วนใหญ่ Web Service จะถูกสร้างมาสำหรับให้ machine หรือ computer ไว้คุยกัน แต่ Web Application นั้นถูกสร้างมาสำหรับ human user

แล้วเราจะสามารถดูได้จากอะไร???

การสื่อสารโดยใช้ HTTP จะมีอยู่ 2 ส่วนคือ Client และ Server

Client ก็คือ Web browser ทั่วไปที่เราใช้เล่นเน็ตกัน เช่น Firefox หรือ Chrome ส่วน Server ก็เป็นโปรแกรมหนึ่งที่อยู่บนคอมพิวเตอร์ซักแห่งบนโลก

การสื่อสารระหว่างจะ client และ server จะมี message อยู่ 2 แบบ คือ request และ response โดยที่:

  • message จาก client ไปหา server จะเรียกว่า request
  • message จาก server ไปหา client จะเรียกว่า response

โดยที่ message จะมีอยู่ 2 ส่วนเช่นกัน คือ head และ body ทั้ง head และ body จะถูกแยกออกจากกันด้วยบรรทัดว่าง หรือ empty line ตัวอย่างเช่น

HTTP/1.1 200 OK
Content-Type: text/html
Set-Cookie: user_id=12345; Expires=Sat, 18 Nov 2023 12:00:00 GMT; Path=/
Content-Length: 54

<!DOCTYPE html>
<html>
<head>
<title>Sample Response</title>
</head>
<body>
<h1>Welcome to our website!</h1>
</body>
</html>

ส่วนนี้จะเรียกว่า Head หรือ Header:

HTTP/1.1 200 OK
Content-Type: text/html
Set-Cookie: user_id=12345; Expires=Sat, 18 Nov 2023 12:00:00 GMT; Path=/
Content-Length: 54

ส่วนล่างนี้จะเรียกว่า Body:

<!DOCTYPE html>
<html>
<head>
<title>Sample Response</title>
</head>
<body>
<h1>Welcome to our website!</h1>
</body>
</html>

โดยส่วนใหญ่เราจะสามารถแยกระหว่าง Web Application และ Web Service โดยใช้ Content-Type ในส่วน Head

ถ้า Content-Type เป็น text/html จะเป็น Web Application นอกจากนั้นจะเป็น Web Service เช่น Content-Type: application/json เป็นต้น

--

--