网站首页 > web开发 > XML 正文
Web 服务描述语言(Web Services Description Language,WSDL)提供了一种描述 Web 服务(大多使用 SOAP)的简单方法。WSDL 允许您描述利用 SOAP 标准所提供的服务和接口。
比方说,可以创建描述某台服务器上提供的服务的 WSDL 文件,然后把该文件分发给需要这些服务的 Web 服务消费者。通过阅读和解析 WSDL 文件,消费者能够了解到使用这些 Web 服务需要知道的所有信息,包括可以交换的数据类型、参数以及返回的各种错误和其他信息。
再次使用来自 W3C 的例子,可以看到不同远程函数的声明和交换的数据都是通过结构的 XML 定义处理的,如清单 3 所示。
清单 3. 不同远程函数和交换数据的 XML 定义
<?xml version="1.0"?> <!-- root element wsdl:definitions defines set of related services --> <wsdl:definitions name="EndorsementSearch" targetNamespace="http://namespaces.snowboard-info.com" xmlns:es="http://www.snowboard-info.com/EndorsementSearch.wsdl" xmlns:esxsd="http://schemas.snowboard-info.com/EndorsementSearch.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <!-- wsdl:types encapsulates schema definitions of communication types; here using xsd --> <wsdl:types> <!-- all type declarations are in a chunk of xsd --> <xsd:schema targetNamespace="http://namespaces.snowboard-info.com" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <!-- xsd definition: GetEndorsingBoarder [manufacturer string, model string] --> <xsd:element name="GetEndorsingBoarder"> <xsd:complexType> <xsd:sequence> <xsd:element name="manufacturer" type="string"/> <xsd:element name="model" type="string"/> </xsd:sequence> </xsd:complexType> </xsd:element> <!-- xsd definition: GetEndorsingBoarderResponse [... endorsingBoarder string ...] --> <xsd:element name="GetEndorsingBoarderResponse"> <xsd:complexType> <xsd:all> <xsd:element name="endorsingBoarder" type="string"/> </xsd:all> </xsd:complexType> </xsd:element> <!-- xsd definition: GetEndorsingBoarderFault [... errorMessage string ...] --> <xsd:element name="GetEndorsingBoarderFault"> <xsd:complexType> <xsd:all> <xsd:element name="errorMessage" type="string"/> </xsd:all> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types> <!-- wsdl:message elements describe potential transactions --> <!-- request GetEndorsingBoarderRequest is of type GetEndorsingBoarder --> <wsdl:message name="GetEndorsingBoarderRequest"> <wsdl:part name="body" element="esxsd:GetEndorsingBoarder"/> </wsdl:message> <!-- response GetEndorsingBoarderResponse is of type GetEndorsingBoarderResponse --> <wsdl:message name="GetEndorsingBoarderResponse"> <wsdl:part name="body" element="esxsd:GetEndorsingBoarderResponse"/> </wsdl:message> <!-- wsdl:portType describes messages in an operation --> <wsdl:portType name="GetEndorsingBoarderPortType"> <!-- the value of wsdl:operation eludes me --> <wsdl:operation name="GetEndorsingBoarder"> <wsdl:input message="es:GetEndorsingBoarderRequest"/> <wsdl:output message="es:GetEndorsingBoarderResponse"/> <wsdl:fault message="es:GetEndorsingBoarderFault"/> </wsdl:operation> </wsdl:portType> <!-- wsdl:binding states a serialization protocol for this service --> <wsdl:binding name="EndorsementSearchSoapBinding" type="es:GetEndorsingBoarderPortType"> <!-- leverage off soap:binding document style ...(no wsdl:foo pointing at the soap binding) --> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <!-- semi-opaque container of network transport details classed by soap:binding above ... --> <wsdl:operation name="GetEndorsingBoarder"> <!-- again bind to SOAP? ... --> <soap:operation soapAction="http://www.snowboard-info.com/ EndorsementSearch"/> <!-- further specify that the messages in the wsdl:operation "GetEndorsingBoarder" use SOAP? ... --> <wsdl:input> <soap:body use="literal" namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/> </wsdl:input> <wsdl:output> <soap:body use="literal" namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/> </wsdl:output> <wsdl:fault> <soap:body use="literal" namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <!-- wsdl:service names a new service "EndorsementSearchService" --> <wsdl:service name="EndorsementSearchService"> <wsdl:documentation>snowboarding-info.com Endorsement Service</ wsdl:documentation> <!-- connect it to the binding "EndorsementSearchSoapBinding" above --> <wsdl:port name="GetEndorsingBoarderPort" binding="es:EndorsementSearchSoapBinding"> <!-- give the binding an network address --> <soap:address location="http://www.snowboard-info.com/EndorsementSearch"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
WSDL 声明了消息类型、默认数据类型和内容以及交换的数据结构。
访问服务器上 SOAP 结构需要使用的一切信息都可以在这个 WSDL 中找到。大多数语言和环境都提供一种阅读和解析 WSDL 的机制,以确定可用的函数和数据交换。
WSDL 不仅定义了用于交换信息的 SOAP 接口,通过适当的 WSDL 生成程序,还可用于创建发送请求、生成并格式化响应所需要的代码。
WSDL 和 SOAP 组成了一个强大的远程过程调用系统。
- 上一篇: XML模式相关常用的缩写词
- 下一篇: XML模式:DocBook XM
猜你喜欢
- 2021-07-16 WAP教程(10):WML参考手册、WML实例和WML DTD-XML/XSLT
- 2021-07-16 WAP教程(11):WAP论坛和开放移动联盟与论坛-XML/XSLT
- 2021-07-16 xml入门教程:XML是什么-XML/XSLT
- 2021-07-16 XML入门教程:XML语法-XML/XSLT
- 2021-07-16 XML入门教程:元素声明-XML/XSLT
- 2021-07-16 XML入门教程:文档类型声明-XML/XSLT
- 2021-07-16 XML入门教程:属性声明-XML/XSLT
- 2021-07-16 XML入门教程:实体-XML/XSLT
- 2021-07-16 XML入门教程:XML名称空间-XML/XSLT
- 2021-07-16 (javascript+asp)XML、XSL转换输出HTML
你 发表评论:
欢迎- 2951℃JS彻底弄懂GMT和UTC时区
- 2822℃JS使用canvas技术模仿echarts柱状图
- 2649℃JS装饰者模式和TypeScript装饰器
- 2574℃JS ES6展开运算符的几个妙用
- 2542℃vue的ssr服务端渲染示例详解
- 2365℃jquery插件实现图片对比
- 2319℃微信小程序视频弹幕位置随机
- 1816℃docker安装redis设置密码并连接的操作
- 0℃未命名
- 开源分类
- 最近发表
-
- (1)python+selenium第一个自动化脚本:实现打开百度首页并搜索selenium
- Discuz!教程之启用HTTPS后解决各处遗留http://网址问题
- 网站如何识别 你是 selenium爬虫?那我们怎么解决(反反爬)
- 旋转拖动验证码解决方案
- python关键词排名_python实现百度关键词排名查询
- Unity3D研究院之通过ipa或apk获取游戏所使用的unity和Xcode版本
- Unity3D研究院编辑器之脚本生成Preset Libraries(十四)
- 手把手教你Charles抓包工具使用
- python开发的程序内存越来越大_遇到个python进程占用内存太多的问题 | 数据,更懂人心...
- Selenium Python3 请求头配置
- 开源网标签
本文暂时没有评论,来添加一个吧(●'◡'●)