WSDL教程 [转]
WSDL教程
WSDL是一种基于XML的语言。
它的作用是描述和访问网页服务。
内容目录
WSDL 介绍
This introduction to WSDL explains what WSDL is.
解释了什么是WSDL
WSDL 文档
This chapter explains the main parts of an WSDL document.
介绍了WSDL文档的主要部分
WSDL 端口
This chapter explains the WSDL port interface.
有关WSDL端口界面的介绍
WSDL 绑定
This chapter explains the WSDL binding interface.
WSDL的绑定界面
WSDL 与 UDDI
Universal Description, Discovery and Integration(全体描述,发现和综合) (UDDI)是一个能够给企业提供注册和搜索服务的网络服务。
WSDL 语法
The full WSDL syntax as listed in the W3C note.
列在W3C笔记上的完整WSDL语法
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
• WSDL是网页服务描述语言 (Web Services Description Language)的缩写 - WSDL is written in XML
• WSDL是以XML形式写成的。 - WSDL is an XML document
• WSDL是一份XML文档 - WSDL is used to describe Web services
• WSDL用于描述网页服务 - WSDL is also used to locate Web services
• WSDL也用于给网页服务定位 - WSDL is not yet a W3C standard
• WSDL目前还不是W3C标准
WSDL Describes Web Services
WSDL描述了网页服务
WSDL stands for Web Services Description Language.
• 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发行。
Go to our W3C Tutorial to read more about specification status and timeline.
请在我们的W3C 教程阅读更多关于详细情况和时间列表的内容。
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作为输出参数的函数
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 messages that 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".的名为“etTermResponse"的输出信息
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"
Universal Description, Discovery and Integration (UDDI) is a directory service where businesses can register and search for Web services.
Universal Description, Discovery and Integration(全体描述,发现和综合) (UDDI)是一个能够给企业提供注册和搜索服务的网络服务。
What is UDDI
什么是UDDI?
UDDI is a platform-independent framework for describing services, discovering businesses, and integrating business services by using the Internet.
UDDI是通过使用英特网描述服务,发现商机,综合商业服务的独立平台框架。
- UDDI stands for Universal Description, Discovery and Integration
• UDDI 代表通用的描述,探索和整合 - UDDI is a directory for storing information about web services
• UDDI是储存网页服务信息的目录。 - UDDI is a directory of web service interfaces described by WSDL
• UDDI是由WSDL描述的网页服务界面的目录 - UDDI communicates via SOAP
• UDDI通过SOAP进行交流 - UDDI is built into the Microsoft .NET platform
• UDDI已被植入Microsoft .NET平台
What is UDDI Based On?
UDDI的建立基础是什么?
UDDI uses World Wide Web Consortium (W3C) and Internet Engineering Task Force (IETF) Internet standards such as XML, HTTP, and DNS protocols.
UDDI使用万维网联盟(W3C)和英特网工程工作小组(IETF)的英特网标准,例如XML, HTTP, 和 DNS 协议。
UDDI uses WSDL to describe interfaces to web services
UDDI使用WSDL描述网页服务的界面
Additionally, cross platform programming features are addressed by adopting SOAP, known as XML Protocol messaging specifications found at the W3C Web site.
此外,交叉平台设计的特点是采用SOAP,SOAP是XML协议信息说明,它可以在W3C网站上找到。
UDDI Benefits
UDDI的好处
Any industry or businesses of all sizes can benefit from UDDI
各式各样的行业或商业都可从UDDI中获益
Before UDDI, there was no Internet standard for businesses to reach their customers and partners with information about their products and services. Nor was there a method of how to integrate into each other's systems and processes.
在UDDI出现之前,还没有英特网标准可供商家们利用,来向他们的顾客传输有关产品和服务的信息。也没有可以互相综合系统和程序的方法。
Problems the UDDI specification can help to solve:
UDDI规格可以帮助解决的问题:
- Making it possible to discover the right business from the millions currently online
使得从当前在线的数百万条信息中找到一条正确的商业信息成为可能。 - Defining how to enable commerce once the preferred business is discovered
定义了一旦更佳的商机出现,怎样使商业活动可实现。 - Reaching new customers and increasing access to current customers
得到新顾客并增加对当前顾客的访问。 - Expanding offerings and extending market reach
扩大供应量和市场范围 - Solving customer-driven need to remove barriers to allow for rapid participation in the global Internet economy
通过解决顾客驱动下的需求问题,以此来扫除障碍,使得可以迅速参与到全球化的英特网经济之中。 - Describing services and business processes programmatically in a single, open, and secure environment
在一个单一的、开放式的、安全的环境中有计划地描述服务和商业过程。
How can UDDI be Used
UDDI怎样被使用
If the industry published an UDDI standard for flight rate checking and reservation, airlines could register their services into an UDDI directory. Travel agencies could then search the UDDI directory to find the airline's reservation interface. When the interface is found, the travel agency can communicate with the service immediately because it uses a well-defined reservation interface.
如果IT产业能发布一份UDDI标准用于飞机航班的走时检验和预定,航空公司会把他们的服务登记到一份UDDI目录里。旅行社可通过搜索UDDI目录来找到航空公司的预定界面。找到界面时,旅行社会立即联系服务,因为预定界面被定义得非常棒。
Who is Supporting UDDI?
谁支持UDDI?
UDDI is a cross-industry effort driven by all major platform and software providers like Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, and Sun, as well as a large community of marketplace operators, and e-business leaders.
UDDI是交叉产业的努力结果,是由所有的重要平台和软件提供商驱动产生的,如:Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, 和Sun,还有市场操作者,电子商务领导组成的大型团体。
Over 220 companies are members of the UDDI community.
220个以上的公司都是UDDI团体的成员。
The full WSDL 1.2 syntax as described in the W3C Working Draft is listed below.
W3C工作草案中描述的全部的WSDL1.2语法都已经在下面列出:
<wsdl:definitions name="nmtoken"? targetNamespace="uri"> <import namespace="uri" location="uri"/> * <wsdl:documentation .... /> ? <wsdl:types> ? <wsdl:message name="ncname"> * <wsdl:portType name="ncname"> * <wsdl:serviceType name="ncname"> * <wsdl:binding name="ncname" type="qname"> * <wsdl:service name="ncname" serviceType="qname"> * </wsdl:definitions> |
WSDL Summary
WSDL摘要
This tutorial has taught you how to create WSDL documents that describes a web service. It also specifies the location of the service and the operations (or methods) the service exposes.
这篇教程已经教了你如何创建用于描述网页服务的WSDL文档。WSDL也指定了服务的位置和服务揭示的操作(或方法)。
You have learned how to define the message format and protocol details for a web service.
你已经学了 怎样为网页服务定义信息格式化和信息协议细节。
You have also learned that you can register and search for web services with UDDI.
你也学到你可以用UDDI注册和搜索网页服务。
Now You Know WSDL, What's Next?
现在你知道WSDL,下步干什么呢?
The next step is to learn about SOAP and Web Services.
下步是学习有关SOAP 和网页服务。
SOAP
SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP.
SOAP 是允许应用程序通过HTTP进行信息交换的一份以XML为基础的简单协议。
Or more simply: SOAP is a protocol for accessing a web service.
或者说得更简单些:SOAP是用于访问网页服务的协议
If you want to learn more about SOAP, please visit our SOAP tutorial.
如果你想了解更多有关SOAP,请访问我们的SOAP 教程。
Web Services
网页服务
Web services can convert your applications into web-applications.
网页服务可以把你的应用程序转换为网页应用程序。
By using XML, messages can be sent between applications.
用XML形式,信息就可以在应用程序之间传递。
If you want to learn more about web services, please visit our Web Services tutorial.
如果你想了解有关更多关于网页服务,请访问我们的网页服务教程Web Services 教程。