A comprehensive introduction to the SOAP protocol

Source: Internet
Author: User

After learning the network protocols for a while, I believe you have some knowledge about some common network protocols. Here we will mainly introduce the content of the SOAP protocol. SOAP Protocol: Simple Object Access Protocol (SOAP), Simple Object Access Protocol (SOAP) is a lightweight, Simple, XML-based Protocol, it is designed to exchange structured and solidified information on the WEB. the SOAP protocol can be used in combination with many existing Internet protocols and formats, including Hypertext Transfer Protocol (HTTP), simple mail Transmission Protocol (SMTP), and multi-purpose Internet Mail Extension protocol (MIME ). it also supports calling RPC from the message system to the remote process) and a large number of applications.

SOAP consists of three parts:

SOAP encapsulation: it defines a framework that describes the content in a message, who should handle it, and whether it is optional or necessary.

SOAP encoding rules: it defines a serialization mechanism for exchanging instances of the data types defined by an application.

Soap rpc representation: it defines the Protocol used to represent Remote Procedure Calls and Responses. RPC: Remote Procedure Call Protocol

RFC-1831) remote process call Protocol)

SOAP messages are basically unidirectional transmission from the sending end to the receiving end, but they are often combined to execute a mode similar to request/response. all SOAP messages are encoded in XML format. a soap message is an XML file that contains an essential SOAP encapsulation package, an optional SOAP header, and a required SOAP block. binding SOAP to HTTP provides the advantages of using SOAP styles, scattered flexibility, and HTTP's rich feature libraries. transmitting SOAP over HTTP does not mean that SOAP will overwrite the existing HTTP semantics, but that the SOAP semantics on HTTP will naturally map to the HTTP semantics. when HTTP is used as the Protocol binding, RPC requests are mapped to HTTP requests, while RPC responses are mapped to HTTP responses. however, using SOAP on RPC is not limited to HTTP binding.

SOAP can also be bound to TCP and UDP protocols.

Protocol Structure

SOAP message format:

SOAP Header

 
 
  1. <SOAP-ENV: Envelope  
  2. Attributes> 
  3. <SOAP-ENV:Body 
  4. Attributes  
  5. </SOAP-ENV:Body> 
  6. </SOAP-ENV:Envelope> 

Currently, it is mainly used in web Services.

SOAP Action WEB encoding is common. The starting meaning of the Protocol is common in the starting sentence of the encoding.

Syntax Rules

Here are some important syntax rules:

SOAP messages must be encoded in XML.

SOAP messages must use the SOAP Envelope namespace

SOAP messages must use the SOAP Encoding namespace

SOAP messages cannot contain DTD references

SOAP messages cannot contain XML processing instructions

Basic Structure of SOAP messages

 
 
  1. <?xml version="1.0"?> 
  2. <soap:Envelope 
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope" 
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> 
  5. <soap:Header> 
  6. ...  
  7. ...  
  8. </soap:Header> 
  9. <soap:Body> 
  10. ...  
  11. ...  
  12. <soap:Fault> 
  13. ...  
  14. ...  
  15. </soap:Fault> 
  16. </soap:Body> 
  17. </soap:Envelope> 

Currently, webservice + soap is quite popular, for the following reasons:

WebService can use XML-based SOAP to represent data and call requests, and transmit data in the XML format through the HTTP protocol, because the call request and response message can pass through the firewall at this time, generally, only port 80 is open. data shows that some of the so-called distributed component technologies implemented before WebService are represented in binary format and need to communicate through special ports. obviously, the firewall will fail. the biggest advantage of webservice is to achieve interoperability between heterogeneous platforms. this is one of the main reasons for using WebService. in this way, any two applications can communicate with each other as long as they can read and write XML.

1. it is easier to deploy webservice directly through network reference. As long as the interface thrown by the server remains the same, the client cannot know it, because internal computing is running on the server) DLL, deployment, to update a DLL, each application must be referenced and updated... IF Ws is used, it is not needed because it is deployed through the network and referenced through the network. Basically, ws has changed, and the client has not been affected, or even does not know such a change...

2. Write a web service, which is similar to a common class.

3. Of course, there is another benefit: platform independence. C #. ws written in Java can call each other.

4. Make a distributed system. For example, write the data access part as ws and publish it on another server ......

Difference between Webservice and WCF:

Webservice integrates technologies such as WEBservice,. NET Remoting, enterprise Service, WSE, and MSMQ. WCF has the advantages of WEBservice and makes up for its shortcomings. however, to enhance the security standardization of WEB Services, Microsoft uses WCF to bind some specifications, making VS Generation Code more rapid and accurate. for example, for the generation and encryption of <Head> protocol nodes, there is still a lot of content here, but I only have access to these two points). In VS2008, WCF implements services through interfaces. it is a little different from implementing WEB SerVCie in VS2005. microsoft intends to integrate WCF into a powerful solution. especially its powerful configuration ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.