没有合适的资源?快使用搜索试试~ 我知道了~
WSDL学习文档(学习web服务必用)
4星 · 超过85%的资源 需积分: 10 17 下载量 68 浏览量
2009-12-03
10:20:40
上传
评论
收藏 66KB DOC 举报
温馨提示
试读
11页
WSDL (Web Services Description Language,Web服务描述语言)是一种XML Application,他将Web服务描述定义为一组服务访问点,客户端可以通过这些服务访问点对包含面向文档信息或面向过程调用的服务进行访问(类似远程过程调用)。WSDL首先对访问的操作和访问时使用的请求/响应消息进行抽象描述,然后将其绑定到具体的传输协议和消息格式上以最终定义具体部署的服务访问点。相关的具体部署的服务访问点通过组合就成为抽象的Web服务。 本文将详细讲解WSDL文档的结构,并分析每个元素的作用。
资源推荐
资源详情
资源评论
WSDL (Web Services Description Language,Web 服务描述语言)是一种
XML Application,他将 Web 服务描述定义为一组服务访问点,客户端可以通
过这些服务访问点对包含面向文档信息或面向过程调用的服务进行访问(类似远
程过程调用)。WSDL 首先对访问的操作和访问时使用的请求/响应消息进行抽
象描述,然后将其绑定到具体的传输协议和消息格式上以最终定义具体部署的
服务访问点。相关的具体部署的服务访问点通过组合就成为抽象的 Web 服务。
本文将详细讲解 WSDL 文档的结构,并分析每个元素的作用。
一:WSDL 定义
WSDL 是一个用于精确描述 Web 服务的文档,WSDL 文档是一个遵循
WSDL XML 模式的 XML 文档。WSDL 文档将 Web 服务定义为服务访问点或
端口的集合。在 WSDL 中,由于服务访问点和消息的抽象定义已从具体的服务
部署或数据格式绑定中分离出来,因此可以对抽象定义进行再次使用:消息,
指对交换数据的抽象描述;而端口类型,指操作的抽象集合。用于特定端口类
型的具体协议和数据格式规范构成了可以再次使用的绑定。将 Web 访问地址与
可再次使用的绑定相关联,可以定义一个端口,而端口的集合则定义为服务。
一 个 WSDL 文 档 通 常 包 含 7 个 重 要 的 元 素 , 即
types、import、message、portType、operation、binding、 service 元
素。这些元素嵌套在 de!nitions 元素中,de!nitions 是 WSDL 文档的根元素。
文章的下一部分将会详细介绍 WSDL 的基本结构。
二:WSDL 的基本结构--概述
如第一部分最后描述的那样,一个基本的 WSDL 文档包含 7 个重要的元素。下
面将分别介绍这几个元素以及他们的作用。
WSDL 文档在 Web 服务的定义中使用下列元素:
· Types - 数据类型定义的容器,它使用某种类型系统(一般地使用
XML Schema 中的类型系统)。
· Message - 通信消息的数据结构的抽象类型化定义。使用 Types
所定义的类型来定义整个消息的数据结构。
· Operation - 对服务中所支持的操作的抽象描述,一般单个
Operation 描述了一个访问入口的请求/响应消息对。
· PortType - 对于某个访问入口点类型所支持的操作的抽象集合,
这些操作可以由一个或多个服务访问点来支持。
· Binding - 特定端口类型的具体协议和数据格式规范的绑定。
· Port - 定义为协议/数据格式绑定与具体 Web 访问地址组合的单个
服务访问点。
· Service- 相关服务访问点的集合。
WSDL 的 xml schema 可 以 参 照 如 下 网 址 :
http://schemas.xmlsoap.org/wsdl/
三:WSDL 的基本结构--详述
本节将通过一个例子详细描述 WSDL 文档每个元素的作用。下面一个例子是一
个简单的 WSDL 文档的内容。
一个简单的 Web Service 的 WSDL 文档,该服务支持名为 sayHello 的唯一操
作,该操作通过在 http 上运行 SOAP 协议来实现的。该请求接受一个字符串
name,经过处理后返回一个简单的字符串。文档如下:
Xml 代码
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:de!nitions
targetNamespace="http://com.liuxiang.x!reDemo/HelloService"
xmlns:tns="http://com.liuxiang.x!reDemo/HelloService"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
attributeFormDefault="quali!ed"
elementFormDefault="quali!ed"
targetNamespace="http://com.liuxiang.x!reDemo/HelloServi
ce">
<xsd:element name="sayHello">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1"
name="name" nillable="true"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="sayHelloResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1"
name="out" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters"
element="tns:sayHelloResponse" />
</wsdl:message>
<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="tns:sayHello" />
</wsdl:message>
<wsdl:portType name="HelloServicePortType">
<wsdl:operation name="sayHello">
<wsdl:input name="sayHelloRequest"
message="tns:sayHelloRequest" />
<wsdl:output name="sayHelloResponse"
message="tns:sayHelloResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloServiceHttpBinding"
type="tns:HelloServicePortType">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHello">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="sayHelloRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloService">
<wsdl:port name="HelloServiceHttpPort"
binding="tns:HelloServiceHttpBinding">
<wsdlsoap:address
剩余10页未读,继续阅读
资源评论
- 23wwwwww2013-07-03写的蛮好的,谢谢
yuwei19840916
- 粉丝: 11
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功