WSDL: Describe your web service

zhaozj2021-02-17  58

WSDL: Describe your web service

Chai Xiaowei

2001-8-13

This article was originally published by the IBM DeveloperWorks China website, its URL is http://www.ibm.com/developerworks/cn/

Web service "stack"

In my previous article, I have introduced the entire technical system of Web services Web Service "Stack", as shown below:

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Management

Quality of Service

Security

Routing, reliability and transaction

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Workflow

WSFL

Service Discovery, Integration

UDDI

Service Description

WSDL

Messaging

SOAP

TRANSPORT

HTTP, FTP, SMTP

Internet

IPv4, IPv6

Among them, the green part is the standard: IP, HTTP, SMTP, etc., which have been previously defined and widely used. The blue part is a standard protocol for Web services currently developed, including service call protocol SOAP, service description protocol WSDL, and service discovery / integrated protocol UDDI, and service workflow description language WSFL. The orange section describes an agreement on routing, reliability, and transaction. The yellow part is a common mechanism for each protocol layer, which is generally completed by an external orthogonal mechanism.

Among them, a Web service that can be used should be used in accordance with a number of features that need to be used without any feature. However, in any case in achieving a general Web service, the infrastructure of Web services: Cross-platform calls and interface can be identified, then WSDL and SOAP are required. SOAP is used to finally complete the web service call, while WSDL is used to describe how to use SOAP to call Web services.

WSDL is an XML Application, which defines the web service description as a set of service access points, and the client can access document information or process-oriented services through these service access points (similar to remote procedure call). WSDL first performs an abstract description of the request / response message used to access the access and access, and then bind it to the specific transport protocol and message format to finally define the specific deployment service access point. The relevant specific deployment service access point is an abstract web service through a combination.

In specifically, we can extend WSDL (similar to SOAP scalability), such that no matter what message format or network protocol is used regardless of communication, you can describe the message format of the service access point and its use. In the WSDL framework, any message format and network protocol can be used, as in the SOAP can use any network protocol. In the WSDL specification, how to use the SOAP message format, HTTP GET / POST message format, and MIME format to complete the Norm of Web Service Interaction.

WSDL overview

Since the communication protocol and message format have reached standardization in the web technology circle, we know that in the usual development process, the Web service is also an object for the INTERFACE of the object, and the web service is also an object, but it is deployed. On the web. Naturally, we also need to have an SDK description document with the interface of this object of the Web service. However, the two are not the same, and the application currently in the Web has fully accepted the basic standard of XML. Basically all newly introduced technologies are based on XML standards, and the two web services target is instant assembly. , Loose coupling and automatic integration, which means that the SDK description document should be the ability to be identified by the machine.

That is, for web services using a standardized message format / communication protocol, it needs to be described in a certain structured way (ie XML) to describe the WEB service call / communication, and it is very important to achieve this. It is a basic guarantee for Web service instant assembly. WSDL is a description language. WSDL defines a set of XML-based syntax that describes the web service as a collection of service access points that can be exchanged, thereby meeting this requirement. The WSDL service is defined as a distributed system to provide a machine-identified SDK document and can be used to describe the details involved in the application communication. The WSDL document defines the web service as a collection of service access points or ports. In WSDL, since the abstraction definition of the service access point and message has been separated from a specific service deployment or data format binding, the abstract definition can be used again: message, refers to the abstract description of the exchange data; and the port type , Referring to an abstract collection of operations. Specific protocols and data format specifications for specific port types constitute bindings that can be used again. Associate a web access address with the re-used binding, you can define a port, and the port of the port is defined as a service. Therefore, the WSDL document uses the following elements in the definition of the web service:

Ÿ Types - Data type defined container, which uses some type of system (generally using type system in XML Schema).

Ÿ Message - Abstract type definition of data structure of communication messages. Use Types defined by Types to define the data structure of the entire message.

Ÿ Operation - Abstract description of the operations supported in the service, typically a single Operation describes a request / response message pair for accessing portions.

Ÿ Port Type - Abstract collection for the operations supported by an access point type, which can be supported by one or more service access points.

Ÿ Binding - The specific protocol and data format specification of specific port types.

Ÿ Port - Defined a single service access point for the protocol / data format binding to the specific web access address.

Ÿ Service - Collection of related service access points.

You can refer to the following picture to understand the structural organization of the WSDL document:

Among them, Types is a container defined by a data type that includes all type definitions of the XML elements required in the message definition, and I will combine XML Schema in the future article to describe how to define how to define.

Message specifically defines the data structure of the message used in the communication, and the Message element contains a set of Part elements, each Part element is an integral part, and each Part references a DataType to represent its structure. Part elements do not support nested (you can use DataType to complete this), all appeared in parallel.

PortType specifically defines a type of service access entry, what is the type of access to the entrance? It is the pattern of incoming / outline messages and its format. A PortType can contain several Operation, and an Operation refers to a type of call supported by access portions. Supports four access portals in WSDL: 1) Single request; 2) Single response; 3) Request / response; 4) Response / request. The request here refers to the server from the client to the web server, and the response refers to the client from the web server. One to two messages of the message definition section will be referenced in the definition of PortType, as the format of the request or response message. For example, a stock query may support two request messages, a request message indicating the stock code, and another request message indicates the name of the stock, the response message may be the price of stocks, etc. .

The above three structures describe the abstraction definition of calling the web service, which is independent of the specific Web service deployment details, which is a reused description (each level can be multiplexed). If compared to the general object language, this part can be the object described by IDL, describing the interface criteria of the object, but which language is implemented, which is the detail specification of which platform, which is deployed? On the machine is described later. Service description is a specific detail of all access portals provided by a specific deployed Web service, and a service will often contain multiple service access portals, while each access portal uses a port element to describe.

Port description is a deployment details of a service access entry, including which web address (URL) is accessed, and how to use what message call mode should be used. The message call mode is represented using a binding structure.

The Binding structure defines a porttype and a specific network transport protocol or message transfer protocol. From this level, the description is related to the deployment of the specific service. For example, you can bind PortType to SOAP / HTTP, or you can bind PortType to MIME / SMTP.

After introducing the main elements of WSDL, everyone will find that WSDL design philosophy completely inherits the consistent design concept of XML-based contemporary web technology standards: open. WSDL allows you to use other types of type definitions (not only XML Schema) to allow multiple network transport protocols and message formats (not just these: SOAP / HTTP, HTTP-GET / POST, and MIME, etc.) . At the same time, WSDL also applies the reuse concept in contemporary software engineering, separating the abstract definition layer and the specific deployment layer, making the abstract definition layer have increased significantly. For example, we can use an abstract definition layer to make an abstortic definition for a class of web services (such as UDDI Registry, abstract definition is exactly consistent with UDDI specification), and different operations can use different specific deployment layers to combine abstraction Define a description of the Web service that completes its own itself.

WSDL document example

The following example is a WSDL definition of a simple Web service providing stock quotes. This service supports a single operation called GetLastTradePrice, which is implemented by running the SOAP 1.1 protocol on HTTP. This request accepts a Tickersymbol of a string and returns the price of the type floating point.

TargetNamespace = "http://example.com/stock quote.wsdl"

XMLns: TNS = "http://example.com/stockquote.wsdl"

XMLns: xsd1 = "http://example.com/stock quote.xsd"

XMLns: soap = "http://schemas.xmlsoap.org/wsdl/soap/"

XMLns = "http://schemas.xmlsoap.org/wsdl/">

XMLns = "http://www.w3.org/1999/xmlschema">

The above part is the definition of the data type, which is the structure of two elements:

Ÿ TRADEPRICEREQUEST: Define the element as a composite type element containing a string element (TickersYmbol).

Ÿ TradePricResult: Define this element as a composite type element containing a floating point element (Price).

This part is an abstract definition of the message format, which defines two message formats:

Ÿ GetLastTradePriceInput (request message format for obtaining the last transaction price): consists of a message snippet, the name of the message is Body, and the specific element type is TRADEPRICEREQUEST. (I have already defined in front)

Ÿ getLastTradePriceOutput (get the response message format of the last transaction price): consists of a message snippet, the name of the message is Body, and the specific element type containing the TRADEPRICERESULT. (I have already defined in front)

This part defines the type of call mode of the service access point, indicating that an inlet type of the StockQuoteService is the request / response mode, the request message is getLastTradePriceInput, and the response message is GetLastTradePriceoutput.

TYPE = "TNS: stockquoteporttype">

Transport = "http://schemas.xmlsoap.org/soap/http" />

SOAPACTION = "http://example.com/getlasttradeprice" />

Namespace = "http://example.com/stockquote.xsd"

EncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/" />

Namespace = "http://example.com/stockquote.xsd"

EncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/" />

This part describes the abstraction definition of the service access point with the SOAP HTTP, describes how to access the access entry deployed by the SOAP / HTTP to access the entry point type of the previously described. The soapaction that should be used in the specific SOAP call is "http://example.com/getlastttradeprice", and the encoding style of the request / response message should use the SOAP specification default code "http: // schema .xmlsoap.org / soap / encoding / ".

Stock Query Service

This part is the definition of the specific web service. In this Web service named StockQuoteService, a service access entry is provided, the access address is "http://example.com/stockquote", the message mode used by the previous Binding is defined.

According to the description of this WSDL document, in the use of the specific web service, the specific SOAP interaction may be as follows:

SOAP message request

POST / stockquote http / 1.1

Host: esample.com

Content-type: text / xml; charSet = "UTF-8"

Content-Length: nnnn

SOAPACTION: "http://example.com/getlasttradeprice"

XMLns: soap-env = "http://schemas.xmlsoap.org/soap/envelop/" SOAP-ENV: EncodingStyle = "http://schemas.xmlsoap.org/soap/encoding/">

XMLns: m = "http://example.com/stock quote.xsd">

MSFT

SOAP message response

HTTP / 1.1 200 ok

Content-type: text / xml; charSet = "UTF-8"

Content-Length: nnnn

XMLns: soap-env = "http://schemas.xmlsoap.org/soap/envelop/"

SOAP-ENV: EncodingStyle = "http://schemas.xmlsoap.org/soap/ENCODING/" />

XMLns: m = "http://example.com/stock quote.xsd">

74.5

summary

In this article, I briefly introduce the use, basic structure and usage method of WSDL specification. After that, I will expand the Element structure of WSDL, while how to apply WSDL in UDDI Registry to discuss.

转载请注明原文地址:https://www.9cbs.com/read-29007.html

New Post(0)