WSDL Overview
OverviewWSDL is an XML application that defines the Web service description as a set of service access points, the client can use these service access points to access services that contain document information or process calls (similar to remote process calls ). WSDL first abstracts the access operations and the request/response messages used for access, then, bind it to the specific transmission protocol and Message format to finally define the service access point for specific deployment. The Service Access Points of specific deployment become abstract web services through combination. In specific use, we can extend the WSDL (similar to the scalability of soap), regardless of the Message format or network protocol used for communication, you can describe the Service Access Point and the message format used. In the WSDL framework, any message format and network protocol can be used, just as any network protocol can be used in soap. The WSDL Specification defines how to use the SOAP message format, http get/post message format, and MIME format to complete Web service interaction.
Since the communication protocols and message formats have been standardized in the Web technology circle, we know that in the general development process, the interface of the object must have the corresponding SDK Description document, web services are also an object, but they are deployed on the web. Naturally, we also need an SDK Description document for the Web service interface. However, the two are different. At present, web applications fully accept the XML standard. Basically, all new technologies are based on the XML standard, secondly, the goal of Web Services is instant assembly, loose coupling, and automatic integration. This means that the SDK Description document should be capable of being recognized by machines. That is to say, for Web services that use standardized message formats/communication protocols, it needs to describe the call/communication of Web Services in a structured way (that is, XML, it is also very important to achieve this, which is the basic guarantee for real-time web service assembly. WSDL is such a descriptive language,
WSDL
Defines a set
XML
Of
Syntax, Set
Web
A service description is a set of service access points that can exchange messages.To meet this requirement. The WSDL service is defined as a machine-recognized SDK document provided by the distributed system and can be used to describe the details involved in the Automatic Execution of Application Communication.
WSDL document
The WSDL document defines a web service as a set of service access points or ports. In WSDL, since the abstract definitions of service access points and messages have been separated from the specific service deployment or data format binding, you can re-use the abstract definition: message, the abstract description of the exchange data, and the port type refers to the abstract set of operations. The specific protocols and data format specifications used for specific port types constitute a reusable binding. Associate the Web access address with the available binding. You can define a port, and the set of ports is defined as a service. Therefore, the WSDL document uses the following elements in the Web service definition:
- Types-a data type-defined container that uses a type system (typically a type system in XML Schema ).
- Message: an abstract and typed definition of the data structure of a communication message. Use the type defined by types to define the data structure of the entire message
- Operation-an abstract description of the operations supported by the Service. Generally, a single operation describes the request/Response Message pair of an access entry.
- Port type-an abstract set of operations supported by an access entry point type. These operations can be supported by one or more service access points.
- Binding-binding of specific protocols and data format specifications for specific port types.
- Port-defines a single service access point that combines protocol/Data Format binding with a specific web access address.
- Service-collection of Service Access Points.
Among them, types is a data type definition container that contains all the types of XML elements required in the message definition, I will explain in detail how to define the type in future articles by combining XML schema. Message specifically defines the data structure of the message used in communication. The message element contains a group of part elements, and each part element is an integral part of the final message, each part references a ype to represent its structure. The part element does not support nesting (datatype can be used to fulfill this requirement. Porttype defines a type of service access entry. What is the type of access entry? The mode and format of the incoming/outgoing message.
One
Porttype
It can contain several
OperationAn operation is a type of call supported by the access entry. Supported in WSDL
Four access entry call Modes: 1) single request; 2) single response; 3) Request/response; 4) response/request. Requests refer to requests from the client to the Web server, and responses refer to requests from the Web server to the client. One or two messages in the message definition section are referenced in the porttype definition as the format of the request or response message. For example, an access entry to a stock query may support two types of request messages. One request message indicates the stock code, and the other request message indicates the stock name, the response message may be the stock price. The above three structures describe the abstract definition of calling Web services. These three parts are reusable and independent from the details of specific Web Service deployment (each layer can be reused ). Compared with the general object language, this part can be called the object described by IDL, which describes the interface standard of the object, but in the end what language the object is implemented, the detailed specifications of the platform to be followed and the machines to be deployed are described by the following elements. The Service describes the deployment details of all access entries provided by a specific deployed Web service,
One
Service
It usually contains multiple service access portals, and each access portal uses one
Port
Element to describe. Port describes the deployment details of a service access portal, including the web address (URL) used for access and the message call mode used for access. The message call mode is represented by the binding structure. The binding structure defines that a porttype is bound to a specific network transmission protocol or message transmission protocol. At this level, the content described is related to the deployment of a specific service. For example, you can bind porttype to soap/HTTP or mime/SMTP.
After introducing the main elements of WSDL, we will find that the design concept of WSDL fully inherits the consistent design concept of XML-based contemporary web technology standards: openness. WSDL allows you to use other types of definition languages (not just XML Schema) by extension, and supports multiple network transmission protocols and message formats (not just those defined in specifications: SOAP/HTTP, HTTP-GET/post and mime ). At the same time, WSDL also applies the reuse concept in contemporary software engineering,Separated the abstract definition layer and specific deployment LayerThis greatly increases the reusability of the abstract definition layer. For example, we can use the abstract definition layer to define an abstract type of web service (for example, the abstract definition of UDDI registry must be completely consistent with the UDDI Specification ), different Operating companies can use different deployment layer descriptions and abstract definitions to describe their own Web Services.
WSDLDocument example
The following example shows the WSDL definition of a simple web service that provides stock quotations. The Service supports a single operation named getlasttradeprice, which is implemented by running the soap 1.1 protocol over HTTP. This request accepts a tickersymbol of the string type and returns the price of the floating point type. <? XML version = "1.0"?> <Definitions name = "stockquote" targetnamespace = http://example.com/stockquote.wsdl xmlns: TNS = "http://example.com/stockquote.wsdl" xmlns: xsd1 = "http://example.com/stockquote.xsd" xmlns: soap = "http://schemas.xmlsoap.org/wsdl/soap/" xmlns = "http://schemas.xmlsoap.org/wsdl/"> <types> <schema targetnamespace = "http://example.com/stockquote.xsd" xmlns = "http://www.w3.org/1999/XMLSchema"> <element name = "tradepricerequest"> <complextype> <all> <element name = "tickersymbol" type = "string"/> </All> </complextype> </element> <element name = "tradepriceresult"> <complextype> <all> <element name = "price" type = "float"/> </All> </complextype> </element> </Schema>
</Types>
The above part is
Data Type Definition, Which defines the structure of two elements:
- Tradepricerequest (transaction price request): defines this element as a composite type element that contains a string element (tickersymbol.
- Tradepriceresult: defines this element as a composite type element that contains a floating point value (price.
<Message name = "getlasttradepriceinput"> <part name = "body" element = "xsd1: tradepricerequest "/> </message> <message name =" getlasttradepriceoutput "> <part name =" body "element =" xsd1: tradepriceresult "/> </message>
Abstract definitions of message formatsTwo message formats are defined:
- Getlasttradepriceinput (Request Message format for obtaining the final transaction price): It is composed of a message segment. The message segment name is body and the specific element type is tradepricerequest. (Previously defined)
- Getlasttradepriceoutput (Response Message format for obtaining the final transaction price): a message segment is composed of a message segment named "body". The specific element type is tradepriceresult. (Previously defined)
<Porttype name = "stockquoteporttype"> <operation name = "getlasttradeprice"> <input message = "TNS: getlasttradepriceinput"/> <Output Message = "TNS: getlasttradepriceoutput "/> </Operation> </porttype>
Type of the call mode of the Service Access PointIndicates that a certain type of entry of stockquoteservice is request/response mode, the request message is getlasttradepriceinput, and the response message is getlasttradepriceoutput. <Binding name = "stockquotesoapbinding" type = "TNS: stockquoteporttype"> <soap: binding style = "document" Transport = "http://schemas.xmlsoap.org/soap/http"/> <operation name = "getlasttradeprice"> <soap: Operation soapaction = "http://example.com/GetLastTradePrice"/> <input> <soap: body use = "literal" namespace = "http://example.com/stockquote.xsd" encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap: body use = "literal" namespace = "http://example.com/stockquote.xsd" encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/> </output> </soap: Operation> </soap: binding> </binding>
Abstract definitions of service access points and
Soap HTTP
BIND,Describes how to use soap/HTTP to access the access entry deployed according to the access entry point type described above. It specifies that the soapaction to be used in a specific soap call is "Listen http://schemas.xmlsoap.org/soap/encoding /". <Service name = "stockquoteservice"> <documentation> stock query service </documentation> <port name = "stockquoteport" binding = "TNS: stockquotebinding"> <soap: address location = "http://example.com/stockquote"/> </port> </service> </Definitions>
This part isSpecificWeb Service DefinitionIn this web service named stockquoteservice, a service access portal is provided, with the access address "http://example.com/stockquote.pdf. The message format used is defined by the previous binding.