WSDL is an XML-based language for describing Web services and how to access them.
WSDL是一种基于XML的语言。它的作用是描述和访问网页服务。
What You Should Already Know
你应该已经知道的
Before you continue you should have a basic understanding of the following:
在你继续下面的学习之前你应该对以下内容有个基本认识:
- XML
- XML Namespaces
XML命名空间 - XML Schema
格式
If you want to study these subjects first, find the tutorials on our Home page.
如果你想先学习这些内容,请看我们主页上的教程。
What is WSDL?
什么是WSDL?
- WSDL stands for Web Services Description Language
&S226; WSDL是网页服务描述语言 (Web Services Description Language)的缩写 - WSDL is written in XML
&S226; WSDL是以XML形式写成的。 - WSDL is an XML document
&S226; WSDL是一份XML文档 - WSDL is used to describe Web services
&S226; WSDL用于描述网页服务 - WSDL is also used to locate Web services
&S226; WSDL也用于给网页服务定位 - WSDL is not yet a W3C standard
&S226; WSDL目前还不是W3C标准
WSDL Describes Web Services
WSDL描述了网页服务
WSDL stands for Web Services Description Language.
&S226; WSDL是网页服务描述语言 (Web Services Description Language)的缩写
WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.
WSDL是以XML语言写成的文档。文档描述了网页服务。它指定了服务的位置并揭示了服务的具体操作。
WSDL Development History at W3C
WSDL在W3C的发展史
WSDL 1.1 was submitted as a W3C Note by Ariba, IBM and Microsoft for describing services for the W3C XML Activity on XML Protocols in March 2001.
2001年3月,Ariba, IBM 和 Microsoft提交WSDL 1.1作为一个W3C Note(注释),用于为XML协议上的W3C XML Activity描述服务。
(a W3C Note is made available by the W3C for discussion only. Publication of a Note by W3C indicates no endorsement by W3C or the W3C Team, or any W3C Members)
(一份W3C注释是W3C提供的仅供讨论的内容。W3C发行的注释并不代表注释经过W3C或W3C工作组,或任何W3C成员的认可和肯定)。
The first Working Draft of WSDL 1.2 was released by W3C in July 2002.
WSDL 1.2的首篇工作草案于2002年7月由W3C发行。
WSDL 文档
w3pop.com / 2006-09-21
A WSDL document is just a simple XML document.
一份WSDL文档是一份简单的XML文档。
It contains set of definitions to describe a web service.
它包含了几组用于描述网页服务的定义。
The WSDL Document Structure
WSDL文档结构
A WSDL document describes a web service using these major elements:
一份WSDL文档用到这些重要元素来描述网页服务:
Element | Defines |
<portType> | The operations performed by the web service |
<message> | The messages used by the web service |
<types> | The data types used by the web service |
<binding> | The communication protocols used by the web service |
The main structure of a WSDL document looks like this:
一份WSDL文档的主要结构会像这样:
<definitions> <types> |
A WSDL document can also contain other elements, like extension elements and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.
一份WSDL文档可能也会包含其他元素,像extension(扩展)元素和service(服务)元素,service元素可以把若干个网页服务的定义合在一起放在一份单独的WSDL文档里。
For a complete syntax overview go to the chapter WSDL Syntax.
想了解关于全部语法,请阅读WSDL Syntax.这章。
WSDL Ports
WSDL端口
The <portType> element is the most important WSDL element.
<portType>元素是最重要的WSDL元素
It describes a web service, the operations that can be performed, and the messages that are involved.
它描述了网页服务,可进行的操作,以及涉及到的信息。
The <portType> element can be compared to a function library (or a module, or a class) in a traditional programming language.
<portType>元素可以比喻为传统设计语言里的函数库(或一个模块,一个类)
WSDL Messages
WSDL信息
The <message> element defines the data elements of an operation.
<message>元素定义了一项操作的数据元素。
Each message can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.
每条信息都由一部分或几部分组成。这些部分可比作是在传统设计语言里被调用的函数的参数。
WSDL Types
WSDL类型
The <types> element defines the data type that are used by the web service.
<types>元素定义了被网页服务所用的数据类型。
For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.
为了最大限度的平台中立,WSDL用XML格式语法来定义数据类型。
WSDL Bindings
WSDL 捆绑
The <binding> element defines the message format and protocol details for each port.
<binding>元素为每个端口定义了信息格式化和协议细节。
WSDL Example
WSDL举例
This is a simplified fraction of a WSDL document:
下面是一份WSDL文档的简化了的片段:
<message name="getTermRequest"> <portType name="glossaryTerms"> |
In this example the <portType> element defines "glossaryTerms" as the name of a port, and "getTerm" as the name of an operation.
在这个例子里<portType>元素把"glossaryTerms"定义为一个端口的名称,"getTerm"定义为一项操作的名称。
The "getTerm" operation has an input message called "getTermRequest" and an output message called "getTermResponse".
"getTerm"操作有一条"getTermRequest"的输入信息和一条"getTermResponse".的输出信息
The <message> elements define the parts of each message and the associated data types.
<message>元素定义了每条元素的部分(part)和相联系的数据类型。
Compared to traditional programming, glossaryTerms is a function library, "getTerm" is a function with "getTermRequest" as the input parameter and getTermResponse as the return parameter.
与传统程序设计相比,glossaryTerms是个函数库,"getTerm"是个以"getTermRequest"作为输入参数,getTermResponse作为输出参数的函数
WSDL 端口
w3pop.com / 2006-09-21
A WSDL port describes the interfaces (legal operations) exposed by a web service.
WSDL端口描述了由网页服务所揭示的界面(interface)(合法操作)
WSDL Ports
WSDL端口
The <portType> element is the most important WSDL element.
<portType>元素是最重要的WSDL元素。
It defines a web service, the operations that can be performed, and the messagesthat are involved.
它定义了网页服务,可进行的操作,以及涉及到的信息。
The port defines the connection point to a web service. It can be compared to a function library (or a module, or a class) in a traditional programming language. Each operation can be compared to a function in a traditional programming language.
端口定义了与网页服务的连接点。它可以比作是传统设计语言里的函数库(或一块模板,或一个类)。每项操作可比成是传统设计语言里的一个函数。
Operation Types
操作类型
The request-response type is the most common operation type, but WSDL defines four types:
请求—回操作类型是最常见的操作类型,但WSDL定义的有四种:
Type | Definition |
One-way | The operation can receive a message but will not return a response |
Request-response | The operation can receive a request and will return a response |
Solicit-response | The operation can send a request and will wait for a response |
Notification | The operation can send a message but will not wait for a response |
One-Way Operation
单向操作
A one-way operation example:
单向操作的例子:
<message name="newTermValues"> <portType name="glossaryTerms"> |
In this example the port "glossaryTerms" defines a one-way operation called "setTerm".
在这个例子里"glossaryTerms端口定义了称作"setTerm".的单向操作
The "setTerm" operation allows input of new glossary terms messages using a "newTermValues" message with the input parameters "term" and "value". However, no output is defined for the operation.
"setTerm"操作允许利用输入参数为“term"和"value"的名为"newTermValues"的信息进行大量全新条款信息的输入。但是,这项操作没有定义有关输出的内容。
Request-Response Operation
请求—回复 操作
A request-response operation example:
一个“请求—回复”操作的例子:
<message name="getTermRequest"> <portType name="glossaryTerms"> |
In this example the port "glossaryTerms" defines a request-response operation called "getTerm".
这个例子里端口"glossaryTerms"定义了一个名为"getTerm"的“请求—回复”操作
The "getTerm" operation requires an input message called "getTermRequest" with a parameter called "term", and will return an output message called "getTermResponse" with a parameter called "value".
"getTerm"操作需要一个参数为"term"的名为"getTermRequest"的输入信息,并且会返回一条参数为"value".的名为“getTermResponse"的输出信息
WSDL 绑定
w3pop.com / 2006-09-21
WSDL bindings defines the message format and protocol details for a web service.
WSDL 绑定(bindings)定义了网页服务的信息格式和协议细节
Binding to SOAP
绑定到SOAP
A request-response operation example:
一个要求—响应操作例子
<message name="getTermRequest"> <portType name="glossaryTerms"> <binding type="glossaryTerms" name="b1"> |
The binding element has two attributes - the name attribute and the type attribute.
Binding元素有两个属性—name(名称)属性和type(类型)属性
The name attribute (you can use any name you want) defines the name of the binding, and the type attribute points to the port for the binding, in this case the "glossaryTerms" port.
Name属性(你可以任意起名称)定义了绑定的名称,type属性指向了用于绑定的端口,在这个例子里端口是"glossaryTerms"
The soap:binding element has two attributes - the style attribute and the transport attribute.
soap:binding元素有两个属性—style(种类)属性和transport(运送)属性
The style attribute can be "rpc" or "document". In this case we use document. The transport attribute defines the SOAP protocol to use. In this case we use HTTP.
Style属性可以是"rpc" 或"document".在这个例子里我们用"document"属性。Transport属性定义了使用的SOAP协议。这个例子里我们用HTTP
The operation element defines each operation that the port exposes.
Operation元素定义了每项揭示端口操作。
For each operation the corresponding SOAP action has to be defined. You must also specify how the input and output are encoded. In this case we use "literal".
对每项操作而言,相应的SOAP行为都必须被定义。你也必须指定输入和输出是怎样被编码的。在这个例子里我们用"literal"