Definition of WEB Service
It is defined by the consortium as a software system designed to support interoperability between machines across the network. Web service services are often defined as a set of modular APIs that can be invoked over the network to perform a remote system's request service.
Here we look at the Web service from a programmer's perspective. In the traditional program coding, there are all kinds of function method calls. Usually, we know the method A in the program module M, give it a call request, and pass in the parameter P required by the A method, after which the method a completes, returns the processing result R. This function or method invocation usually occurs in the same program language environment on the same machine. Now we need a kind of ability to implement function and method invocation through network communication in application systems written in different languages between different computers, and Web service is born to this kind of demand.
The most common term is that Web Service = SOAP + HTTP + WSDL. Where the SOAP simple Object Access Protocol protocol is the principal of a Web service, it communicates through an application-layer protocol such as HTTP or SMTP, using an XML file to describe the function method and parameter information of the program. Thus the computation service processing between heterogeneous systems of different hosts is accomplished. The WSDL (Web Services Description Language) Web Service Description Language is also an XML document that is published via HTTP to the public, announcing the URL information, method naming of a specific WEB service services by the client program, parameters, return values, and so on.
Next, let's familiarize ourselves with the SOAP protocol and see how it describes the function methods, parameters, and result objects in the program.
Introduction to the SOAP protocol
What is Soap
SOAP refers to a simple Object access protocol, which is an xml-based message communication format for communication between applications on a network, on different platforms, and in different languages. Customizable, easy to scale. A SOAP message is an ordinary XML document that contains the following elements:
envelope element that identifies a SOAP message in an XML document
header element, XML tag containing header information
BODY element that contains the label of the principal information for all calls and responses
fault element, error message label.
The above elements are declared in the soap namespace Http://www.w3.org/2001/12/soap-envelope;
Syntax rules for soap
SOAP messages must be encoded in XML
SOAP messages must use the SOAP Envelope namespace
SOAP messages must use the SOAP Encoding namespace
SOAP message cannot contain DTD reference
SOAP messages cannot contain XML processing directives
Basic structure of SOAP messages
[Java]View plain copy? XML version= "1.0"?> <soap:envelope xmlns:soap= "Http://www.w3.org/2001/12/soap-envelope" Http://www.w3.org/2001/12/soap-encoding "> <soap:Header> ... </soap:Header> <soap:body& Gt ... <soap:Fault> ... </soap:Fault> </soap:Body> </SOAP:ENVELOPE&G. ... T
SOAP Envelope Element
The Envelope element is the root element of the SOAP message. It indicates that the XML document is a SOAP message. The value of its property xmlns:soap must be http://www.w3.org/2001/12/soap-envelope.
encodingstyle property, Syntax: soap:encodingstyle= "URI"
The Encodingstyle property is used to define the data type used in the document. This property can appear in any SOAP element and will be applied to the contents of the element and to all child elements of the element.
[Java]View plain copy? XML version= "1.0"?> <soap:envelope xmlns:soap= "Http://www.w3.org/2001/12/soap-envelope" Http://www.w3.org/2001/12/soap-encoding "> ... Message information goes ... </soap:Envelope>
SOAP Header Element
Actor property, Syntax soap:actor= "URI"
By passing through different endpoints along the message path, the SOAP message can be propagated from one sender to the receiver. Not all parts of the SOAP message are intended to be routed to the final endpoint of the SOAP message, but another aspect may be intended to be routed to one or more endpoints on the message path. The actor property of SOAP can be used to address Header elements to a specific endpoint.
MustUnderstand property, Syntax soap:mustunderstand= "0|1"
The MustUnderstand property of SOAP can be used to identify whether a header item is mandatory or optional for the recipient to process it. If you add "mustunderstand=" 1 to a child element of the header element, the recipient that handles this header must approve this element.
[Java]View plain copy? XML version= "1.0"?> <soap:envelope xmlns:soap= "Http://www.w3.org/2001/12/soap-envelope" Http://www.w3.org/2001/12/soap-encoding "> <soap:Header> <m:trans xmlns:m=" http://www.jsoso.net/ transaction/"soap:mustunderstand=" 1 "soap:actor=" http://www.w3schools.com/appml/">234</m:Trans> </ Soap:header> ... </soap:Envelope>
SOAP BODY Element
The required SOAP BODY element can contain the actual SOAP message that is intended to be delivered to the final endpoint of the message. The BODY element can contain both elements of a SOAP-defined namespace, such as fault, or a user's application-customized element. The following is a user-defined request:
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.