WSDL-学习总结
1.什么是WSDL
是一种使用 XML 编写的文档。这种文档可描述某个 Web service。它可规定服务的位置,以及此服务提供的操作(或方法)。
2.WSDL文档结构:
<binding> | web service 使用的通信协议;为每一个<protTypes>定义消息格式和通信协议;有services引用; |
<portType> | web service 可以执行的操作(operation)相当于一个函数库,其中定义的每一个操作可以被看做是一个函数;被binding调用; |
<message> | web service 使用的消息;被operation调用,相当于函数的参数,有入参(input)和出参(output);message中的part,指定函数中的参数名和参数类型; |
<types> | web service 使用的数据类型;被<message>调用;在<types>中定义了元素以及元素的类型; |
以GetServices为例
////////////////////////////////<types>
<wsdl:types>
<xs:schema targetNamespace="http://www.onvif.org/ver10/device/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" elementFormDefault="qualified" version="18.12">
<xs:import namespace="http://www.onvif.org/ver10/schema" schemaLocation="../../../ver10/schema/onvif.xsd"/>
<!--===============================-->
<xs:element name="GetServices">
<xs:complexType>
<xs:sequence>
<xs:element name="IncludeCapability" type="xs:boolean">
<xs:annotation>
<xs:documentation>Indicates if the service capabilities (untyped) should be included in the response.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetServicesResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Service" type="tds:Service" maxOccurs="unbounded"> //这里需要注意的是,"type= "tds:Service""指定的类型是下面的complexTpye name = "Service"
<xs:annotation>
<xs:documentation>Each Service element contains information about one service.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!--===============================-->
<xs:complexType name="Service"> //自定义一种复杂的数据类型 “Service”,请求消息或者响应消息时需要严格按照数据类型格式;
<xs:sequence>
<xs:element name="Namespace" type="xs:anyURI"> //这里的“anyURL”是xml schmea中的杂项数据类型,表示Namespace元素值可以是任意类型的URI;
<xs:annotation>
<xs:documentation>Namespace of the service being described.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="XAddr" type="xs:anyURI">
<xs:annotation>
<xs:documentation>The transport addresses where the service can be reached.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Capabilities" minOccurs="0"> //表示<Capabilities>元素最少可以出现0次;如果不明确声明出现的次数,则元素最少出现一次,最多出现一次
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax">
<xs:annotation>
<xs:documentation>The placeholder for the service capabilities.</xs:documentation>
</xs:annotation>
</xs:any>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Version" type="tt:OnvifVersion">
<xs:annotation>
<xs:documentation>The version of the service (not the ONVIF core spec version).</xs:documentation>
</xs:annotation>
</xs:element>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> //<any> 元素使我们有能力可以使用未被 schema 规定的元素来拓展 XML 文档!
</xs:sequence>
<xs:anyAttribute processContents="lax"/> //<anyAttribute> 元素使我们有能力使用未被 schema 规定的属性来扩展 XML 文档!
</xs:complexType>
</wsdl:types>
///////////////////////////////<message>
<wsdl:message name="GetServicesRequest">
<wsdl:part name="parameters" element="tds:GetServices"/> //把massage定义了操作的参数:part则是定义的参数;
</wsdl:message>
<wsdl:message name="GetServicesResponse">
<wsdl:part name="parameters" element="tds:GetServicesResponse"/>
</wsdl:message>
///////////////////////////////<portType>
<wsdl:portType name="Device">
<wsdl:operation name="GetServices">
<wsdl:documentation>Returns information about services on the device.</wsdl:documentation>
<wsdl:input message="tds:GetServicesRequest"/>
<wsdl:output message="tds:GetServicesResponse"/>
</wsdl:operation>
</wsdl:portType>
////////////////////////////////<binding>
<wsdl:binding name="DeviceBinding" type="tds:Device"> //指向binding的端口,此处指向“Device”;
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> //style取值只能为“rpc”或者“document”;transport定义了要使用的SOAP协议,这里使用http;
<wsdl:operation name="GetServices">
<soap:operation soapAction="http://www.onvif.org/ver10/device/wsdl/GetServices"/> //定义了每个端口提供的操作符;
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
下图概要描述了<binding>,<message>,<types>,<portTypes>之间的关系
1.箭头连接符代表文档不同栏之间的关系。
2.点和箭头代表了引用或使用关系。
3.双箭头代表"修改"关系。
4.3-D的箭头代表了包含关系。
这样,
各Messages栏使用Types栏的定义;
PortTypes栏使用Messages栏的定义;
Bindings栏引用了PortTypes栏;
Services栏引用Bindings栏;
PortTypes和Bindings栏包含了operation元素,而Services栏包含了port元素。
PortTypes栏里的operation元素由Bindings栏里的operation元素进一步修改或描述。
WSDL-学习总结的更多相关文章
- wsdl学习
本文来自 :迹忆 原文地址:http://www.onmpw.com/tm/xwzj/network_47.html 在刚开始学习Webservice的时候,发现里面涉及到的知识点还真不少,每一点单拿 ...
- web services + soap + wsdl 学习
什么是web services? 应用程序组件: 使用开放协议进行通信: 独立(self - contained )并可自我描述: 可通过使用UDDI来发现: 可被其他应用程序使用: XML是Web ...
- Android通过ksoap2这个框架调用webservice大讲堂
昨天有人问我Android怎么连接mysql数据库,和对数据库的操作呀,我想把,给他说说json通信,可是他并不知道怎么弄,哎算了吧,直接叫他用ksoap吧,给他说了大半天,好多零碎的知识,看来还是有 ...
- webService学习之路(三):springMVC集成CXF后调用已知的wsdl接口
webService学习之路一:讲解了通过传统方式怎么发布及调用webservice webService学习之路二:讲解了SpringMVC和CXF的集成及快速发布webservice 本篇文章将讲 ...
- Web Service学习笔记(webservice、soap、wsdl、jws详细分析)
Web Service概述 Web Service的定义 W3C组织对其的定义如下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的API ...
- Web Service学习笔记(webservice、soap、wsdl、jws详细分析) (转)
Web Service概述 Web Service的定义 W3C组织对其的定义如下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的API ...
- webservice学习01:wsdl文档结构
webservice学习01:wsdl文档结构 wsdl文档结构 WSDL文档示例 <wsdl:definitions xmlns:xsd="http://www.w3.org/200 ...
- CXF学习(3) wsdl文件
<!--一次webservice调用,其实并不是方法调用,而是发送SOAP消息 ,即xml片段--> <!--以上一篇中的wsdl文档为例,这里我将注释写到文档中 --> &l ...
- Web Service学习之五:WSDL详解
WSDL是Web Service定义文档,不同平台 不同语言实现Web Service遵循的共同协议 ,在解析XML时按照各自语言的特点解析成相应的具体类.方法.参数和数据类型. WSDL是一个XML ...
- php学习之道:WSDL具体解释(三)
通过声明方式定义绑定(binding)属性 假设你在服务中採用SOAP binding.你能够使用JAX-WS来指定一定数量的属性binding. 这些属性指定相应你在WSDL中指定的属性.某些设置. ...
随机推荐
- LeetCode解题报告—— Bus Routes
We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For e ...
- 给定一列数字将其平移n位
原题的意思是给定一个指定长度的数组,然后接受一个数字m,将原数组前m位移动到最后,且顺序不变. 看到这个题,想到的第一个方法就是在用一个数组来储存改变后的数字,代码如下 int func(){ int ...
- Centos7yum安装LNMP
(1)安装nginx 0.关闭防火墙 systemctl stop firewald.service systemctl disable firewald.service 1.使用nginx官方提供的 ...
- PHP 扩展安装
PHP版本 >= 5.6.4 PHP扩展:OpenSSL --- 已经有啦 PHP扩展:PDO PHP扩展:Mbstring PHP扩展:Tokenizer PHP扩展:XML .安装php ...
- Sqlite的导入导出功能
导出,使用dump命令 导入,使用read命令 可以直接执行,类似 sqlite xxx.db3 ".read ../sss.sql"
- B. Black Square(字符串)
B. Black Square time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 计蒜客 UCloud 的安全秘钥(困难)(哈希)
UCloud 的安全秘钥(困难) 编辑代码 9.53% 1200ms 262144K 每个 UCloud 用户会构造一个由数字序列组成的秘钥,用于对服务器进行各种操作.作为一家安全可信的云计算平台,秘 ...
- 文件包含漏洞检测工具fimap
文件包含漏洞检测工具fimap 在Web应用中,文件包含漏洞(FI)是常见的漏洞.根据包含的文件不同,它分为本地文件包含漏洞(LFI)和远程文件包含漏洞(RFL).利用该漏洞,安全人员可以获取服务 ...
- BestCoder Round #65 (ZYB's Premutation)
ZYB's Premutation Accepts: 220 Submissions: 983 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- [Atcoder Regular Contest 061] Tutorial
Link: ARC061 传送门 C: 暴力$dfs$就好了 #include <bits/stdc++.h> using namespace std; typedef long long ...