Web Services - Lecture 1: Exam Questions and Answers
Q1. Explain the three-tier architecture with a neat diagram.
Three-tier architecture is a software design pattern that separates an application into three main logical
layers:
1. Presentation Layer (Frontend)
- This is the user interface layer where users interact with the application.
- It captures input from users (e.g., login forms, search queries) and displays output.
- Technologies: HTML, CSS, JavaScript, React, etc.
2. Business Logic Layer (Application/Backend Layer)
- Processes user input and applies the core functionality or rules of the application.
- Acts as a bridge between the frontend and the database.
- Technologies: Node.js, Django, Laravel, Spring Boot.
3. Data Layer (Database)
- Responsible for storing and retrieving data.
- Technologies: MySQL, MongoDB, PostgreSQL.
Diagram:
[ Client Browser ]
->
[ Presentation Layer ]
->
[ Business Logic Layer ]
->
[ Data Layer (Database) ]
Advantages:
- Modular development.
- Easy maintenance and scalability.
- Improved security by isolating data from UI.
Web Services - Lecture 1: Exam Questions and Answers
Q2. Compare SOAP and REST web services in detail.
SOAP (Simple Object Access Protocol) and REST (Representational State Transfer) are web service models
for communication between client and server.
SOAP:
- Protocol-based.
- Uses XML exclusively.
- Relies on WSDL for description.
- Heavier and enterprise-level usage.
REST:
- Architectural style.
- Uses standard HTTP methods.
- Supports JSON, XML, and other formats.
- Lightweight and suitable for mobile/web.
Comparison:
| Feature | SOAP | REST |
|----------------|------------------------------|-----------------------------------|
| Type | Protocol | Architecture |
| Data Format | XML only | JSON, XML, HTML, Text |
| Speed | Slower | Faster |
| Security | WS-Security | HTTPS based |
| State | Stateless | Stateless/Stateful |
| Use Case | Enterprise | Web/mobile apps |
Conclusion:
Use SOAP for high security and reliability; REST for lightweight and modern apps.
Q3. Describe the client-server architecture. How is it different from three-tier architecture?
Web Services - Lecture 1: Exam Questions and Answers
Client-Server Architecture:
- Client sends request; server processes and returns response.
- Example: Web browser (client) communicates with web server.
Three-Tier Architecture:
- Extends client-server by splitting server into:
a. Business Logic Layer
b. Data Layer
Comparison:
| Feature | Client-Server | Three-Tier |
|---------------------|------------------|---------------------------|
| Layers |2 |3 |
| Separation | Basic | Clear Modular Structure |
| Scalability | Moderate | High |
| Maintenance | Less Flexible | Easier |
Conclusion:
Three-tier architecture offers more modularity and is better suited for large apps.
Q4. Explain how data flows in a web application using the three-tier model.
In three-tier architecture, the data flow works as follows:
1. Presentation Layer:
- User sends request (e.g., login, search).
2. Business Logic Layer:
- Processes request, applies logic, interacts with database.
3. Data Layer:
Web Services - Lecture 1: Exam Questions and Answers
- Stores or retrieves necessary data and sends it back.
Example (Login):
- User enters credentials (frontend).
- Backend validates and checks DB.
- Response sent to user with result.
Conclusion:
Each layer handles specific tasks ensuring separation of concerns and efficient communication.
Q5. You are building an online bookstore. Explain how you would structure it using three-tier
architecture.
Presentation Layer:
- Displays book listings, search, cart, and forms.
- Technologies: React, HTML/CSS.
Business Logic Layer:
- Handles login, order processing, checkout logic.
- Technologies: Node.js, Django.
Data Layer:
- Stores book data, user info, orders.
- Technologies: MySQL, MongoDB.
Example Flow:
1. User selects a book.
2. Backend processes order.
3. Database updates inventory.
Conclusion:
Using three-tier model improves scalability, modularity, and separation of concerns.
Web Services - Lecture 1: Exam Questions and Answers
Q6. Your mobile app wants to fetch weather data from a server. Would you use SOAP or
REST? Justify your answer.
REST is preferred for mobile apps due to:
1. Lightweight: Uses JSON (faster and smaller than XML).
2. Simplicity: Uses standard HTTP (GET, POST).
3. Scalability: Stateless and faster.
Example REST API call:
GET https://api.weatherapi.com/v1/current.json?key=API_KEY&q=Kathmandu
Conclusion:
REST is ideal for mobile due to better speed, simplicity, and efficiency over SOAP.
Q7. In a web-based login system, map each component to the correct layer of the three-tier
architecture.
Presentation Layer:
- Login form (HTML/CSS/JS)
Business Logic Layer:
- Processes login credentials, validation, session management.
Data Layer:
- Stores user credentials and session data (e.g., in MySQL).
Flow:
1. User submits form.
2. Backend validates against DB.
3. User receives success/failure message.
Web Services - Lecture 1: Exam Questions and Answers
Conclusion:
Each layer plays a key role in handling UI, logic, and data securely and efficiently.