AJAX & Web Services
AJAX & Web Services
AJAX & Web Services
AJAX is a new technique for creating better, faster and more interactive web
applications with the help of XML, HTML, CSS and JavaScript. It uses XHTML for
content, CSS for presentation, along with Document Object Model and JavaScript for
dynamic content display. Conventional web applications transmit information to and
from the server using synchronous requests, which means the user fill out a form,
hit submit and get directed to a new page with new information from the server.
With Ajax, when the user hit submit, javascript will make a request to the
server, interpret the results and update the current screen. The user would never
know that anything was even transmitted to the server. XML is commonly used as
the format for receiving server data. AJAX is a web browser technology independent
of web server software. AJAX is a data driven technology. The technologies that
support AJAX are: Javascript, DOM, CSS and XMLHttpRequest.
AJAX is based on the following open standards:
Browser based presentation using HTML and CSS.
Data is stored in XML format and fetched from the server.
Behind the scenes data fetching is done using XMLHttpRequest objects in the
browser.
Javascript to make everything happen.
Example:
AJAX Client Server Architecture
Client Side Ajax transformations:
With client side Ajax, the Ajax engine runs on the client. The server delivers
web content (HTML, CSS, JavaScript, etc) which is processed by the client- side Ajax
engine into revised web content. The browser renders the revised HTML etc, content
that comes out of the Ajzx engine. With this architecture, the application
development team typically provides the following server side components: Web
pages (eg., *.html, *.php. *.jsp, *.asp), applications logic (e.g., Java) and data
management (e.g., via SQL database and /or web services)
Example:
Refer AJAX
XMLHttpRequest Object
The XMLHttpRequest object is used to exchange data with a server behind the
scenes. This means that is possible to update parts of a web page, without loading
reloading the whole page. XMLHttpRequest (XHR) is an API that can be used by
JavaScript, Jscript, VBScript and other web browser scripting languages to transfer
and manipulate XML data to and from a webserver using HTTP, establishing an
independent connection channel between a webpage’s client side and server side.
The data returned from XMLHttpRequest calls will often be provided by back end
database. Besides XML, XMLHttpRequest can be used to fetch data in other formats,
example JSON or even plain text.
Creating an XMLHttpRequest Object
Syntax:
variable=new xmlhttprequest(); (new version)
variable= new Activexobject(“microsoft.xmlhttp”); (old version)
Request Methods:
Response Properties:
Example:
Refer AJAX
Web Services
A web services is a collection of open protocols and standards used for
exchanging data between applications or systems. Web services are technology, a
process and a phenomenon. Web services are built on top of open standards such as
TCP/IP, HTTP, Java, HTML and XML. XML is used to encode all communications to a web
service.
Web services include programs, objects, messages or documents. They are
available over the internet or private networks. They are not tied to any one operating
system or programming language. They are self-describing through a common XML
grammar. They are discoverable through a simple find mechanism.
Components of Web Service:
The basic web services platform is XML + HTTP. All the standard web services
work using the following components.
Java web services (JAX – WS)
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)
Working of Web Service:
A web service enables communication among various applications by suing open
standards such as HTML, XML, WSDL and SOAP. A web service takes the help of XML to
tag the data, SOAP to transfer a message, WSDL to describe the availability of service,
Java – based web service can also be built.
Example:
WSDL
WSDL stands for Web Services Description Language. It is the standard format for
describing a web service. WSDL definitions describe how to access a web service and
what operations it will perform. A client program connecting to a web service can read
the WSDL to determine what functions are available on the server. The client can then
use SOAP to actually call one of the functions listed in the WSDL.
WSDL document uses the following elements in the definition of network services:
Types– a container for data type definitions using some type system (such as
XSD).
Message– an abstract, typed definition of the data being communicated.
Operation– an abstract description of an action supported by the service.
Port Type–an abstract set of operations supported by one or more endpoints.
Binding– a concrete protocol and data format specification for a particular port
type.
Port– a single endpoint defined as a combination of a binding and a network
address.
Service– a collection of related endpoints.
Example:
SOAP
SOAP is an acronym for Simple Object Access Protocol. It is an XML-based
messaging protocol for exchanging information among computers. SOAP is an
application of the XML specification.
SOAP is a communication protocol designed to communicate via Internet.
SOAP can extend HTTP for XML messaging.
SOAP provides data transport for Web services.
SOAP can be used for broadcasting a message.
SOAP is platform- and language-independent.
A SOAP message is an ordinary XML document containing the following elements:
Envelope − Defines the start and the end of the message. It is a mandatory
element.
Header − Contains any optional attributes of the message used in processing the
message, either at an intermediary point or at the ultimate end-point. It is an
optional element.
Body − Contains the XML data comprising the message being sent. It is a
mandatory element.
Fault − An optional Fault element that provides information about errors that
occur while processing the message.
Example:
*****