Escolar Documentos
Profissional Documentos
Cultura Documentos
AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better, faster, and more
interactive web applications with the help of XML, HTML, CSS, and Java Script.
Ajax 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. It means you
fill out a form, hit submit, and get directed to a new page with new information from the server.
With AJAX, when you hit submit, JavaScript will make a request to the server, interpret the results, and update the
current screen. In the purest sense, the user would never know that anything was even transmitted to the server.
XML is commonly used as the format for receiving server data, although any format, including plain text, can be used.
A user can continue to use the application while the client program requests information from the server in the
background.
Intuitive and natural user interaction. Clicking is not required, mouse movement is a sufficient event trigger.
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
Send a Request To a Server
To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object:
xhttp.open("GET",
xhttp.send();
Method
open(method, url, async)
send()
send(string)
"ajax_info.txt",
Description
Specifies the type of request
method: the type of request: GET or POST
url: the server (file) location
async: true (asynchronous) or false (synchronous)
Sends the request to the server (used for GET)
Sends the request to the server (used for POST)
GET or POST?
GET is simpler and faster than POST, and can be used in most cases.
However, always use POST requests when:
Sending a large amount of data to the server (POST has no size limitations).
Sending user input (which can contain unknown characters), POST is more robust and secure than GET.
GET Requests
A simple GET request:
Example
xhttp.open("GET", "demo_get.asp", true);
xhttp.send();
In the example above, you may get a cached result. To avoid this, add a unique ID to the URL:
Example
xhttp.open("GET", "demo_get.asp?t=" + Math.random(), true);
xhttp.send();
If you want to send information with the GET method, add the information to the URL:
true);
Example
xhttp.open("GET", "demo_get2.asp?fname=Henry&lname=Ford", true);
xhttp.send();
POST Requests
A simple POST request:
Example
xhttp.open("POST", "demo_post.asp", true);
xhttp.send();
To POST data like an HTML form, add an HTTP header with setRequestHeader(). Specify the data you want to send in the
send() method:
Example
xhttp.open("POST", "ajax_test.asp", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("fname=Henry&lname=Ford");
Method
Description
Adds HTTP headers to the request
setRequestHeader(header
, value)
header: specifies the header name
value: specifies the header value
The url - A File On a Server
The url parameter of the open() method, is an address to a file on a server:
xhttp.open("GET", "ajax_test.asp", true);
The file can be any kind of file, like .txt and .xml, or server scripting files like .asp and .php (which can perform actions on the
server before sending the response back).
Async=true
When using async=true, specify a function to execute when the response is ready in the onreadystatechange event:
Example
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
You will learn more about onreadystatechange in a later chapter.
Async=false
To use async=false, change the third parameter in the open() method to false:
xhttp.open("GET", "ajax_info.txt", false);
Using async=false is not recommended, but for a few small requests this can be ok.
Remember that the JavaScript will NOT continue to execute, until the server response is ready. If the server is busy or slow, the
application will hang or stop.
Note: When you use async=false, do NOT write an onreadystatechange function - just put the code after the send() statement:
Example
xhttp.open("GET", "ajax_info.txt", false);
xhttp.send();
document.getElementById("demo").innerHTML = xhttp.responseText;
Parameters
Here is the description of all the parameters used by this method
callback The function to execute. The event object, XMLHttpRequest, and settings used for that request are passed
as arguments to the callback.
Example
Assuming we have following HTML content in result.html file
<h1>THIS IS RESULT...</h1>
Following is a simple example a simple showing the usage of this method.
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
/* Global variable */
var count = 0;
$("#driver").click(function(event){
$('#stage0').load('result.html');
});
/* Gets called when request starts */
$(document).ajaxStart(function(){
count++;
$("#stage1").html("<h1>Starts, Count :" + count + "</h1>");
});
/* Gets called when request is sent */
$(document).ajaxSend(function(evt, req, set){
count++;
$("#stage2").html("<h1>Sends, Count :" + count + "</h1>");
$("#stage2").append("<h1>URL :" + set.url + "</h1>");
});
/* Gets called when request completes */
$(document).ajaxComplete(function(event,request,settings){
count++;
$("#stage3").html("<h1>Completes,Count:" + count + "</h1>");
});
/* Gets called when request is stopped */
$(document).ajaxStop(function(event,request,settings){
count++;
$("#stage4").html("<h1>Stops, Count :" + count + "</h1>");
6
});
/* Gets called when all request completes successfully */
$(document).ajaxSuccess(function(event,request,settings){
count++;
$("#stage5").html("<h1>Success,Count :" + count + "</h1>");
});
});
</script>
</head>
<body>
<p>Click on the button to load result.html file:</p>
<div id = "stage0" style = "background-color:blue;">
STAGE - 0
</div>
<div id = "stage1" style = "background-color:blue;">
STAGE - 1
</div>
<div id = "stage2" style = "background-color:blue;">
STAGE - 2
</div>
<div id = "stage3" style = "background-color:blue;">
STAGE - 3
</div>
<div id = "stage4" style = "background-color:blue;">
STAGE - 4
</div>
<div id = "stage5" style = "background-color:blue;">
STAGE - 5
</div>
<input type = "button" id = "driver" value="Load Data" />
</body>
</html>
AJAX is an acronym standing for Asynchronous JavaScript and XML and this technology help us to load data from the server
without a browser page refresh.
If you are new with AJAX, I would recommend you go through our Ajax Tutorial before proceeding further.
JQuery is a great tool which provides a rich set of AJAX methods to develop next generation web application.
Loading simple data
This is very easy to load any static or dynamic data using JQuery AJAX. JQuery provides load() method to do the job
7
Syntax
Here is the simple syntax for load() method
[selector].load( URL, [data], [callback] );
Here is the description of all the parameters
URL The URL of the server-side resource to which the request is sent. It could be a CGI, ASP, JSP, or PHP script
which generates data dynamically or out of a database.
data This optional parameter represents an object whose properties are serialized into properly encoded parameters
to be passed to the request. If specified, the request is made using the POST method. If omitted, the GET method is
used.
callback A callback function invoked after the response data has been loaded into the elements of the matched set.
The first parameter passed to this function is the response text received from the server and second parameter is the
status code.
Example
Consider the following HTML file with a small JQuery coding
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("#driver").click(function(event){
$('#stage').load('/jquery/result.html');
});
});
</script>
</head>
<body>
<p>Click on the button to load /jquery/result.html file </p>
<div id = "stage" style = "background-color:cc0;">
STAGE
</div>
<input type = "button" id = "driver" value = "Load Data" />
</body>
</html>
Here load() initiates an Ajax request to the specified URL /jquery/result.html file. After loading this file, all the content would be
populated inside <div> tagged with ID stage. Assuming, our /jquery/result.html file has just one HTML line
<h1>THIS IS RESULT...</h1>
8
When you click the given button, then result.html file gets loaded.
Getting JSON data
There would be a situation when server would return JSON string against your request. JQuery utility function getJSON()
parses the returned JSON string and makes the resulting string available to the callback function as first parameter to take
further action.
Syntax
Here is the simple syntax for getJSON() method
[selector].getJSON( URL, [data], [callback] );
Here is the description of all the parameters
URL The URL of the server-side resource contacted via the GET method.
data An object whose properties serve as the name/value pairs used to construct a query string to be appended to
the URL, or a preformatted and encoded query string.
callback A function invoked when the request completes. The data value resulting from digesting the response body
as a JSON string is passed as the first parameter to this callback, and the status as the second.
Example
Consider the following HTML file with a small JQuery coding
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("#driver").click(function(event){
$.getJSON('/jquery/result.json', function(jd) {
$('#stage').html('<p> Name: ' + jd.name + '</p>');
$('#stage').append('<p>Age : ' + jd.age+ '</p>');
$('#stage').append('<p> Sex: ' + jd.sex+ '</p>');
});
});
});
</script>
</head>
<body>
<p>Click on the button to load result.json file </p>
<div id = "stage" style = "background-color:#eee;">
STAGE
9
</div>
<input type = "button" id = "driver" value = "Load Data" />
</body>
</html>
Here JQuery utility method getJSON() initiates an Ajax request to the specified URL result.json file. After loading this file, all
the content would be passed to the callback function which finally would be populated inside <div> tagged with ID stage.
Assuming, our result.json file has following json formatted content
{
"name": "Zara Ali",
"age" : "67",
"sex": "female"
}
When you click the given button, then result.json file gets loaded.
Passing data to the Server
Many times you collect input from the user and you pass that input to the server for further processing. JQuery AJAX made it
easy enough to pass collected data to the server using data parameter of any available Ajax method.
Example
This example demonstrate how can pass user input to a web server script which would send the same result back and we
would print it
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("#driver").click(function(event){
var name = $("#name").val();
$("#stage").load('/jquery/result.php', {"name":name} );
});
});
</script>
</head>
<body>
<p>Enter your name and click on the button:</p>
<input type = "input" id = "name" size = "40" /><br />
<div id = "stage" style = "background-color:cc0;">
STAGE
</div>
<input type = "button" id = "driver" value = "Show Result" />
10
</body>
</html>
Here is the code written in result.php script
<?php
if( $_REQUEST["name"] ){
$name = $_REQUEST['name'];
echo "Welcome ". $name;
}
?>
Now you can enter any text in the given input box and then click "Show Result" button to see what you have entered in the
input box.
JQuery AJAX Methods
You have seen basic concept of AJAX using JQuery. Following table lists down all important JQuery AJAX methods which you
can use based your programming need
S.N
Methods & Description
.
jQuery.ajax( options )
1
Load a remote page using an HTTP request.
jQuery.ajaxSetup( options )
2
Setup global settings for AJAX requests.
jQuery.get( url, [data], [callback], [type] )
3
Load a remote page using an HTTP GET request.
jQuery.getJSON( url, [data], [callback] )
4
Load JSON data using an HTTP GET request.
jQuery.getScript( url, [callback] )
5
Loads and executes a JavaScript file using an HTTP GET request.
jQuery.post( url, [data], [callback], [type] )
6
Load a remote page using an HTTP POST request.
load( url, [data], [callback] )
7
Load HTML from a remote file and inject it into the DOM.
serialize( )
8
Serializes a set of input elements into a string of data.
serializeArray( )
9 Serializes all forms and form elements like the .serialize() method but returns a JSON
data structure for you to work with.
JQuery AJAX Events
You can call various JQuery methods during the life cycle of AJAX call progress. Based on different events/stages following
methods are available
You can go through all the AJAX Events.
S.N. Methods & Description
ajaxComplete( callback )
1
Attach a function to be executed whenever an AJAX request completes.
2
ajaxStart( callback )
11
Attach a function to be executed whenever an AJAX request begins and there is none already active.
ajaxError( callback )
Attach a function to be executed whenever an AJAX request fails.
ajaxSend( callback )
Attach a function to be executed before an AJAX request is sent.
ajaxStop( callback )
Attach a function to be executed whenever all AJAX requests have ended.
ajaxSuccess( callback )
Attach a function to be executed whenever an AJAX request completes successfully.
3
4
5
6
5.4 WEB SERVICES: INTRODUCTIONWeb services are open standard (XML, SOAP, HTTP etc.) based Web applications that interact with other web applications for
the purpose of exchanging data.
Web Services can convert your existing applications into Web-applications.
Different books and different organizations provide different definitions to Web Services. Some of them are listed here.
A web service is any piece of software that makes itself available over the internet and uses a standardized XML
messaging system. XML is used to encode all communications to a web service. For example, a client invokes a web
service by sending an XML message, then waits for a corresponding XML response. As all communication is in XML,
web services are not tied to any one operating system or programming language--Java can talk with Perl; Windows
applications can talk with Unix applications.
Web services are self-contained, modular, distributed, dynamic applications that can be described, published, located,
or invoked over the network to create products, processes, and supply chains. These applications can be local,
distributed, or web-based. Web services are built on top of open standards such as TCP/IP, HTTP, Java, HTML, and
XML.
Web services are XML-based information exchange systems that use the Internet for direct application-to-application
interaction. These systems can include programs, objects, messages, or documents.
A web service is a collection of open protocols and standards used for exchanging data between applications or
systems. Software applications written in various programming languages and running on various platforms can use
web services to exchange data over computer networks like the Internet in a manner similar to inter-process
communication on a single computer. This interoperability (e.g., between Java and Python, or Windows and Linux
applications) is due to the use of open standards.
All these components have been discussed in the Web Services Architecture chapter.
How Does a Web Service Work?
A web service enables communication among various applications by using open standards such as HTML, XML, WSDL, and
SOAP. A web service takes the help of:
You can build a Java-based web service on Solaris that is accessible from your Visual Basic program that runs on Windows.
You can also use C# to build new web services on Windows that can be invoked from your web application that is based on
JavaServer Pages (JSP) and runs on Linux.
Example
Consider a simple account-management and order processing system. The accounting personnel use a client application built
with Visual Basic or JSP to create new accounts and enter new customer orders.
The processing logic for this system is written in Java and resides on a Solaris machine, which also interacts with a database to
store information.
The steps to perform this operation are as follows:
The client program bundles the account registration information into a SOAP message.
13
This SOAP message is sent to the web service as the body of an HTTP POST request.
The web service unpacks the SOAP request and converts it into a command that the application can understand.
The application processes the information as required and responds with a new unique account number for that
customer.
Next, the web service packages the response into another SOAP message, which it sends back to the client program
in response to its HTTP request.
The client program unpacks the SOAP message to obtain the results of the account registration process.
14
WSDL is an XML-based protocol for information exchange in decentralized and distributed environments.
WSDL definitions describe how to access a web service and what operations it will perform.
WSDL is an integral part of Universal Description, Discovery, and Integration (UDDI), an XML-based worldwide
business registry.
15
WSDL Usage
WSDL is often used in combination with SOAP and XML Schema to provide web services over the Internet. A client program
connecting to a web service can read the WSDL to determine what functions are available on the server. Any special datatypes
used are embedded in the WSDL file in the form of XML Schema. The client can then use SOAP to actually call one of the
functions listed in the WSDL.
History of WSDL
WSDL 1.1 was submitted as a W3C Note by Ariba, IBM, and Microsoft for describing services for the W3C XML Activity on XML
Protocols in March 2001.
WSDL 1.1 has not been endorsed by the World Wide Web Consortium (W3C), however it has just released a draft for version
2.0 that will be a recommendation (an official standard), and thus endorsed by the W3C.
WSDL breaks down web services into three specific, identifiable elements that can be combined or reused once defined.
The three major elements of WSDL that can be defined separately are:
Types
Operations
Binding
A WSDL document has various elements, but they are contained within these three main elements, which can be developed as
separate documents and then they can be combined or reused to form complete WSDL files.
WSDL Elements
A WSDL document contains the following elements:
Definition : It is the root element of all WSDL documents. It defines the name of the web service, declares multiple
namespaces used throughout the remainder of the document, and contains all the service elements described here.
Data types : The data types to be used in the messages are in the form of XML schemas.
Message : It is an abstract definition of the data, in the form of a message presented either as an entire document or
as arguments to be mapped to a method invocation.
Operation : It is the abstract definition of the operation for a message, such as naming a method, message queue, or
business process, that will accept and process the message.
Port type : It is an abstract set of operations mapped to one or more end-points, defining the collection of operations
for a binding; the collection of operations, as it is abstract, can be mapped to multiple transports through various
bindings.
Binding : It is the concrete protocol and data formats for the operations and messages defined for a particular port
type.
16
Port : It is a combination of a binding and a network address, providing the target address of the service
communication.
Service : It is a collection of related end-points encompassing the service definitions in the file; the services map the
binding to the port and include any extensibility definitions.
In addition to these major elements, the WSDL specification also defines the following utility elements:
Documentation: This element is used to provide human-readable documentation and can be included inside any
other WSDL element.
Import : This element is used to import other WSDL documents or XML Schemas.
NOTE: WSDL parts are usually generated automatically using web services-aware tools.
The WSDL Document Structure
The main structure of a WSDL document looks like this:
<definitions>
<types>
definition of types........
</types>
<message>
definition of a message....
</message>
<portType>
<operation>
definition of a operation.......
</operation>
</portType>
<binding>
definition of a binding....
</binding>
<service>
definition of a service....
</service>
</definitions>
A WSDL document can also contain other elements, like extension elements and a service element that makes it possible to
group together the definitions of several web services in one single WSDL document.
Proceed further to analyze an example of WSDL Document.
WSDL - <definition> Element
he <definitions> element must be the root element of all WSDL documents. It defines the name of the web service.
Here is the piece of code from the last chapter that uses the definitions element.
17
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
................................................
</definitions>
From the above example, we can conclude that definitions:
specifies a targetNamespace attribute. The targetNamespace is a convention of XML Schema that enables the WSDL
document to refer to itself. In this example, we have specified a targetNamespace of
http://www.examples.com/wsdl/HelloService.wsdl
specifies numerous namespaces that are used throughout the remainder of the document.
18
19
01
02
03
04
05
06
07
08
09
10
11
12
13
14
package com.theopentutorials.ws.calc;
import javax.jws.WebService;
@WebService
public class Calculator {
public int add(int a, int b) {
return (a + b);
}
public int sub(int a, int b) {
return (a - b);
}
}
4. @WebService annotation at the beginning of the class definition tells the Java interpreter that we intend to publish ALL
the methods of this class as a web service. If we want to publish only particular methods then we can use
@WebMethod annotation before the method signature.
20
5. In order to publish our class and its methods as web service we need to crate appropriate stub files or artifacts for web
service deployment and invocation. Fortunately Java provides a tool called wsgen which generates JAX-WS portable
artifacts used in JAX-WS web services.
6. Open command prompt or terminal in Linux and go to the project folder CalcWS.
7. Now issue the following command,
wsgen -cp bin -d bin com.theopentutorials.ws.calc.Calculator
the cp option specifies the classpath for our Calculator class which is in bin folder, the d option specifies where to
place generated output files which is also the bin folder in our case.
8. We can also have a look at the source of the generated files by using the s option provided by wsgen.
wsgen -s src -cp bin -d bin com.theopentutorials.ws.calc.Calculator
21
9. Now we need to publish our class as a web service endpoint. For that we use the static publish() method of the
javax.xml.ws.Endpoint class to publish our Calculator class as a web service in the specified context root.
22
11. Create a class CalcEndpointPublisher with main method and type the following code.
23
01
02
03
04
05
06
07
08
09
10
11
12
13
package com.theopentutorials.ws.calc.endpoint;
import javax.xml.ws.Endpoint;
import com.theopentutorials.ws.calc.Calculator;
public class CalcEndpointPublisher {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/CalcWS/Calculator",
new Calculator());
}
}
24
3. Just like wsgen, JAX-WS also provides a tool called wsimport for generating the artifacts required for creating and
consuming a web service. wsimport takes a wsdl file as input.
4. From the project folder in command prompt or terminal, issue the following command,
wsimport -s src -d bin http://localhost:8080/CalcWS/Calculator?wsdl
25
5. This will generate many files as shown in the below file hierarchy tree.
6. Let us now create a Java class with main method to run this client. Create a package
com.theopentutorials.ws.calc.client
26
7. In that package, create a class CalcClient with main method and type the following code.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
package com.theopentutorials.ws.calc.client;
import com.theopentutorials.ws.calc.Calculator;
import com.theopentutorials.ws.calc.CalculatorService;
public class CalcClient {
public static void main(String[] args) {
int a = 10;
int b = 12;
CalculatorService calcService = new CalculatorService();
Calculator calc = calcService.getCalculatorPort();
System.out.println(a + " + " + b + " = " + calc.add(a, b));
System.out.println(a + " - " + b + " = " + calc.sub(a, b));
}
}
JDK 1.6
NetBeans 6.1
Fig.
Step 2:
28
Fig. 2.
Step 3:
Type the driver name, url , user name and password as shown below in Fig. 3.
Fig. 3
Step 4:
It shows the all the tables of the database test as shown below in Fig 4.
29
Fig. 4
Step 5:
Fig. 5
Step 6:
It opens a dialog box for giving the fields name of the table
Now give the field name and data type as shown below in Fig 6.
30
Fig. 6
Step 7:
Click on the Ok
Fig. 7
Step 9:
31
Fig. 8
Step 10:
Click on the Next and then finish button as shown below in Fig 9.
Fig. 9
Step 11:
32
Fig. 10
Step 13:
Type the name of the WebService as myaccount with the package as mypack.
Fig. 11
Step 14:
33
Fig. 12
Step 15:
Fig. 13
Step 16:
34
Fig. 14
Step 17:
35
Fig. 15
Step 18:
In the choose database select the Add button as shown below in Fig 16.
Fig. 16
Step 19:
For Project Data Sources Click on the Add button as shown below in Fig 17.
Fig. 17
Step 20:
In the database connection select the newly created database connction for the mysql.
as shown below in Fig 18.
36
Fig. 18
Step 21:
It creates the database connection gives the dialog box as shown below.
Fig. 19
5.9 SOAP
SOAP is an open-standard, XML-based messaging protocol for exchanging information among computers. This is a
brief tutorial that introduces the readers to the fundamentals of SOAP before moving on to explain its various elements,
encoding, and how SOAP is transported.
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.
Points to Note
Below mentioned are some important point which the user should take note of. These points briefly describes the nature of
SOAP
37
SOAP is the XML way of defining what information is sent and how.
SOAP enables client applications to easily connect to remote services and invoke remote methods.
Although SOAP can be used in a variety of messaging systems and can be delivered via a variety of transport protocols, the
initial focus of SOAP is remote procedure calls transported via HTTP.
Other frameworks including CORBA, DCOM, and Java RMI provide similar functionality to SOAP, but SOAP messages are
written entirely in XML and are therefore uniquely 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.
All these elements are declared in the default namespace for the SOAP envelope
http://www.w3.org/2001/12/soap-envelope and the default namespace for SOAP encoding and data types is
http://www.w3.org/2001/12/soap-encoding
NOTE All these specifications are subject to change. So keep updating yourself with the latest specifications available on the
W3 website.
SOAP Message Structure
The following block depicts the general structure of a SOAP message
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope"
ENV:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<SOAP-ENV:Header>
...
...
</SOAP-ENV:Header>
38
SOAP-
<SOAP-ENV:Body>
...
...
<SOAP-ENV:Fault>
...
...
</SOAP-ENV:Fault>
...
</SOAP-ENV:Body>
</SOAP_ENV:Envelope>
SOAP with HTTP POST
The following example illustrates the use of a SOAP message within an HTTP POST operation, which sends the message to
the server. It shows the namespaces for the envelope schema definition and for the schema definition of the encoding rules.
The OrderEntry reference in the HTTP header is the name of the program to be invoked at the tutorialspoint.com website.
POST /OrderEntry HTTP/1.1
Host: www.tutorialspoint.com
Content-Type: application/soap; charset="utf-8"
Content-Length: nnnn
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope"
http://www.w3.org/2001/12/soap-encoding">
...
Message information goes here
...
</SOAP-ENV:Envelope>
39
SOAP-ENV:encodingStyle="