SOAP Introduction
时间:2010-06-04 来源:lqseu
SOAP is a simple XML-based protocol to let applications exchange information over HTTP.
HTTP + XML = SOAP
Or more simply: SOAP is a protocol for accessing a Web Service.
What is SOAP?
•SOAP stands for Simple Object Access Protocol
•SOAP is a communication protocol
•SOAP is for communication between applications
•SOAP is a format for sending messages
•SOAP communicates via Internet
•SOAP is platform independent
•SOAP is language independent
•SOAP is based on XML
•SOAP is simple and extensible
•SOAP allows you to get around firewalls
•SOAP is a W3C recommendation
Why SOAP?
It is important for application development to allow Internet communication between programs.
Today's applications communicate using Remote Procedure Calls (RPC) between objects like DCOM and CORBA, but HTTP was not designed for this. RPC represents a compatibility and security problem; firewalls and proxy servers will normally block this kind of traffic.
A better way to communicate between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was created to accomplish this.
SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.
SOAP Syntax
A SOAP message is an ordinary XML document containing the following elements:
•An Envelope element that identifies the XML document as a SOAP message
•A Header element that contains header information
•A Body element that contains call and response information
•A Fault element containing errors and status information
===========================================================
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
------The namespace defines the Envelope as a SOAP Envelope
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
------ encodingStyle is used to define data types used in the document
<soap:Header>
------header contains application-specific information (eg: authentication, payment, etc)
------if the header element is present, it must be the first child element of the Envelope element
...
</soap:Header>
<soap:Body>
------contains the actual SOAP message intended for the ultimate endpoint of the message.
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>
</soap:Envelope>
------SOAP defines 3 default attributes in the default namespace: mustUnderstand, actor, encodingStyle
============================================================
src: http://www.w3schools.com/soap/soap_example.asp