Web Application Architecture
Web Application Architecture
[1]Web Architecture:
[2]MVC
[3]middleware
[4]Design considerations
[5]Issues in web application design
[6]Security issues
[7]interoperability issues (WS-I).
MVC Architecture:
MVC stands for Model, View and Controller. MVC separates application into
three components - Model, View and Controller.
Model: Model represents shape of the data and business logic. It maintains
the data of the application. Model objects retrieve and store model state in
a database.
View: View is a user interface. View display data using model to the user
and also enables them to modify the data.
The following figure illustrates the interaction between Model, View and
Controller.
MVC Architecture
The following figure illustrates the flow of the user's request in ASP.NET
MVC.
Request/Response in MVC Architecture
As per the above figure, when the user enters a URL in the browser, it goes
to the server and calls appropriate controller. Then, the Controller uses the
appropriate View and Model and creates the response and sends it back to
the user.
Security issues:
https://searchsecurity.techtarget.com/tip/Security-issues-with-Web-
services
RPC:
Remote Procedure Call (RPC) is a protocol that one program can use to
request a service from a program located in another computer on
a network without having to understand the network's details. A procedure
call is also sometimes known as a function call or a subroutine call.
RPC uses the client-server model. The requesting program is a client and
the service providing program is the server. Like a regular or local
procedure call, an RPC is a synchronous operation requiring the requesting
program to be suspended until the results of the remote procedure are
returned. However, the use of lightweight processes or threads that share
the same address space allows multiple RPCs to be performed
concurrently.
When program statements that use RPC framework are compiled into an
executable program, a stub is included in the compiled code that acts as the
representative of the remote procedure code. When the program is run and the
procedure call is issued, the stub receives the request and forwards it to a
client runtime program in the local computer.
The client runtime program has the knowledge of how to address the remote
computer and server application and sends the message across the network that
requests the remote procedure. Similarly, the server includes a runtime program
and stub that interface with the remote procedure itself. Response-request protocols
are returned the same way.
Sample Program of RPC
import java.util.Vector;
import java.util.Scanner;
import java.util.Hashtable;
import helma.xmlrpc.*;
import helma.xmlrpc.WebServer;
String s1 = in.nextLine();
String s2 = in.nextLine();
System.out.println("Number 1 :"+s1);
System.out.println("Number 2 "+s2);
params.addElement(new Integer(s1));
params.addElement(new Integer(s2));
Integer.toString(exception.code) + ":
" + exception.toString());
} catch (Exception exception) {
System.err.println("JavaClient: " +
exception.toString());
}
}
}
Server Code:
import logging
# Set up logging
logging.basicConfig(level=logging.INFO)
server = SimpleXMLRPCServer(
('localhost', 7070),
logRequests=True,
)
# Expose a function
def sum(a,b):
return a+b
def diff(a,b):
return a-b
def multiply(a,b):
return a*b
server.register_function(sum)
server.register_function(diff)
server.register_function(multiply)
server.serve_forever()
except KeyboardInterrupt:
print('Exiting')
JAVA RMI
The RMI (Remote Method Invocation) is an API that provides a mechanism to create
distributed application in java. The RMI allows an object to invoke methods on an object
running in another JVM.
The RMI provides remote communication between the applications using two
objects stub and skeleton.
A remote object is an object whose method can be invoked from another JVM. Let's
understand the stub and skeleton objects:
stub
The stub is an object, acts as a gateway for the client side. All the outgoing requests are
routed through it. It resides at the client side and represents the remote object. When
the caller invokes method on the stub object, it does the following tasks:
skeleton
The skeleton is an object, acts as a gateway for the server side object. All the incoming
requests are routed through it. When the skeleton receives the incoming request, it does
the following tasks:
In the Java 2 SDK, an stub protocol was introduced that eliminates the need for
skeletons.
3) create the stub and skeleton objects using the rmic tool.
1. rmic AdderRemote
Serialization
import java.io.Serializable;
public Student() {
}