Sunday, 17 April 2011

3 Tier Architecture


3 Tier Model contains following layers

1) Application Layer
2) Business Layer(Property Layer(Sub layer of Business Layer))
3) Data Layer

* Application layer is a from where we design using controls like textbox,labels and command buttons etc.

* Business layer is class where we write the functions which get the data from application layer and passes through the data access layer.

* Data layer is also the class which gets the data from business layer and sends it to the database or gets the data from database and sends it to the business layer.

* Property layer is the sub layer of business layer in which we make the properties to set or get the values from the application layer.These properties help to sustain  the value in an object so that we can get these values  till the object destroy.

Data Tier
This tier is responsible for retrieving;storing and updating from information therefore this tier can be ideally represented through a commercial database.Usage of stored procedures increases the performance and code transparency of an application.
Logical Tier
This is the brain of 3 Tier Application.Some of the advantages are
(1)Increases code transparency.
(2)Supports changes in data layer.
Business Tier
Through a website could talk to the data access layer directly,it usually goes through another layer called the business layer.The business layer is vital in that it validates the input conditions before calling a method from the data layer.This insures that the data input is correct  before proceeding, and can often ensure that the outputs are correct as well.
Data Access Layer
This tier acts as an interface to Data tier.This tier known how to (from which database) retrieve and store information.
Presentation Tier
This Tier is responsible for communication with the users and web service consumers and it will use objects from Business layer to response GUI raised events.

Saturday, 9 April 2011

ASP.NET 3.5, AJAX and Web Services

Introduction:
This article explains the use of webservices in ASP.NET 3.5 AJAX environment and it tells how to call web service methods from a client-side javascript. It also outlines the new System.Web.Script namespace and explores the ways of defining the client-call to a web service method. 

Calling WebService methods in AJAX :
To improve the web user experience, the AJAX functionality of ASP.NET has included in its new version, new ways of calling the web service methods from client-side javascript. Without submitting or rendering a whole page, AJAX enables you to call a server-side method with no post-back.
The client script can make a request to a web method and pass data as input parameters to the method; and data can also be sent back to the client browser from the server.
To enable your application to call ASP.NET Web services by using client script, the server asynchronous communication layer automatically generates JavaScript proxy classes. A proxy class is generated for each Web service for which an <asp:ServiceReference> element is included under the <asp:ScriptManager> control in the page .

          <asp:ScriptManager runat="server" ID="scriptManagerId">
                <Scripts>
                    <asp:ScriptReference Path="CallWebServiceMethods.js" />
                </Scripts>
                <Services>
                    <asp:ServiceReference  Path="WebService.asmx" />
                </Services>
           </asp:ScriptManager >

<asp:ScriptReference> element is specified to register a javascript file that is to be used in a web page. Only after registering the CallWebServiceMethod.js file, you can call methods on it. 

Calling a Web service method from script is asynchronous. To get a return value or to determine when the request has returned, you must provide a succeeded callback function. The callback function is invoked when the request has finished successfully, and it contains the return value (if any) from the Web method call. You can also provide a failed callback function to handle errors. Additionally, you can pass user context information to use in the callback functions. 
There are two steps for Consuming web service methods in AJAX . The first step is that there is a slight change in the way you create and define web services. Making calls using client script from a page to the service methods will be the second step. 

Creating a web service : 
In the System.Web.Scripts.Services namespace, you may find an attribute class “[ScriptSrvice ]” and this need to be applied to a webservice class so that the web service methods can be invoked from the client script.
Similarly, in the same namespace, you may find another attribute class “[ScriptMethod ]” and upon applying this attribute to a web method you can specify which HTTP verb is used to invoke a method and the format of the response.JSON – JavaScript Object Notation is the default serialization format using which data transformation takes place between client-server requests.

Call web service methods using Client Script : 
Asp.Net Web Service methods can be called from client scripts asynchronously without a postback and without refreshing the full page.  Only data is transferred between the server and client browser.
Write javascript functions to call the web service methods and callback methods. Calls to Web service methods are made by using the proxy class and a list of parameters, name of the succeeded callback function, the failed callback function, and the user context is passed as additional parameters in the call.

Conclusion:
The ASP.NET 3.5 along with the in-built AJAX client-server framework has increased the power of using client scripts to call webservice methods. Most of the settings and javascript code files are loaded automatically when you use Visual Studio 2008. Calling web service methods in the earlier versions of AJAX, ATLAS has few troubles that make the development and debugging little difficult. Now, with ASP.NET 3.5, it has become an inherent part of the much simpler and familiar VS 2008 IDE. 

I still have a little more work left to-do before our application is done... :-)
My next step will be to setup the overall UI layout of asp .net ajax application, and provide web services within it. 

 
For More Reference visit following URL :