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中指定的属性.某些设置. ...
随机推荐
- 基于UDP套接字编程实例
data.h #ifndef DATA_H #define DATA_H #include <stdio.h> #include <string.h> #include < ...
- 如何简单的测试kubernetes的dns add-ons是否工作正常?
1,新建一个yaml文件. apiVersion: v1 kind: Pod metadata: name: busybox namespace: default spec: containers: ...
- 使用kubeadm安装k8s集群故障处理三则
最近在作安装k8s集群,测试了几种方法,最终觉得用kubeadm应该最规范. 限于公司特别的网络情况,其安装比网上不能访问google的情况还要艰难. 慢慢积累经验吧. 今天遇到的三则故障记下来作参考 ...
- 关于在C#中对抽象类的理解
先说一下自己对类的理解吧.类就是指将一系列具有一些共同特性的事物归纳起来,按照不同的特性分为不同的类.比如在现实世界中人是一类,动物是一类.植物 又是一类.但他们都是生命这一类的派生类.他们都继承了生 ...
- 【剑指offer】面试题 17. 打印从 1 到最大的 n 位数
面试题 17. 打印从 1 到最大的 n 位数 题目描述 题目:输入数字 n,按顺序打印出从 1 最大的 n 位十进制数.比如输入 3,则打印出 1.2.3 一直到最大的 3 位数即 999. 解答过 ...
- cocos2dx 大地图分块加载的研究(初)
http://blog.csdn.net/dinko321/article/details/46739563 http://blog.csdn.net/u012812482/article/detai ...
- 543. Diameter of Binary Tree【Easy】【二叉树的直径】
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...
- SpringMVC中为什么要配置Listener和Servlet
一直以来,我们使用SpringMVC的时候习惯性都配置一个ContextLoaderListener,虽然曾经有过疑问,配置的这个监听器和Servlet究竟做了什么,但也没深究. 要说任何Web框架都 ...
- 第4天:Ansible模块
Ansible对远程服务器的实际操作实际是通过模块完成的,其工作原理如下: 1)将模块拷贝到远程服务器 2)执行模块定义的操做,完成对服务器的修改 3)在远程服务器中删除模块 需要说明的是,Ansib ...
- Git Bash 将本地代码提交到Github
前提:已拥有Token,并且把本地的Token配置到了自己的Github里面(没有Token的自行去百度如何配置Token) 测试一下自己的连接 ssh -T git@github.com 本地操作: ...