Hi,
libsfan01 wrote:
Hi all
Can anyone explain the relationship between SOAP and XMLHttpRequest in
Javascript? What actually is SOAP? and how does it relate to the
process of transferring data client-side through the aforementioned
method?
SOAP (Simple Object Access Protocol) is, like the name shows, a
protocol. It's built on XML, which is handy in the case of a web
application, because it can be transmitted using HTTP.
The main purpose of SOAP is to allow remote procedure calls. SOAP
defines a syntax allowing to describe objects and methods. It can be
produced by a server to expose so-called "web methods". These methods
can be called by a SOAP-compliant remote client, usually in the
following way: the client calls a URL, and the server returns the
description of the methods using the SOAP protocol (this is called WSDL
file, for Web Service Description Language). Based on this WSDL file,
the client builds a proxy, which is an object reacting like the original
remote object, in the sense that it exposes the same methods. When the
client uses the proxy to call the web method, the proxy creates a
request containing the SOAP envelope with the web method call (including
parameters).
The server receives the request and uses the SOAP envelope to map the
call to the web method. The method is executed, and the return value
then encoded in SOAP again and passed back to the web client. Usually
the call is asynchronous, but most clients also support synchronous calls.
The easiest (and most hidden) way to use SOAP to make web service calls
is probably to use .NET's web references. However, SOAP is also easy to
use with Microsoft's new ASP:NET AJAX framework, which provides the
scripts needed to create proxies based on the WSDL files.
XmlHttpRequest is the interface provided by most modern web browsers to
send background HTTP requests to a web server, so it is the transport
object used when you want to make SOAP calls using JavaScript. However,
there is no strict relation between SOAP and XmlHttpRequest. You can use
SOAP without XmlHttpRequests (on some environments), and you can use
XmlHttpRequests without SOAP.
Generally speaking, using SOAP is adding quite a big overhead to a web
application, but also adds a level of comfort. Overhead because you have
to encode/decode the SOAP call every time, and to transmit quite a lot
of XML over the wire. Comfort, because it allows you to use proxies in a
very transparent way, over HTTP and the port 80, and (in the case of a
..NET server) without having to configure anything. .NET takes care of
everything for you, creates the WSDL file, encodes/decodes the SOAP
automatically, very easy.
An example of WSDL file can be seen here:
http://www.galasoft-lb.ch/mydotnet/W...ice1.asmx?WSDL
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering:
http://www.galasoft-LB.ch
PhotoAlbum:
http://www.galasoft-LB.ch/pictures
Support children in Calcutta:
http://www.calcutta-espoir.ch