【WebService】WebService之WSDL文档深入分析(三)
WSDL概念
WSDL(网络服务描述语言,Web Services Description Language)是一门基于 XML 的语言,用于描述 Web Services 以及如何对它们进行访问。
WSDL 文档结构
首先发布一个简单的WebService(参照:【WebService】使用JDK开发WebService(二)),在发布的WebService地址后面加上'?wsdl',得到wsdl文件地址(http://127.0.0.1:8989/test-webservice/hellows?wsdl),使用浏览器打开。
重要标签说明:
types - 数据类型(标签)定义的容器,里面使用schema定义了一些标签结构供message引用
message - 通信消息的数据结构的抽象类型化定义。引用types中定义的标签
operation - 对服务中所支持的操作的抽象描述,一个operation描述了一个访问入口的请求消息与响应消息对。
portType - 对于某个访问入口点类型所支持的操作的抽象集合,这些操作可以由一个或多个服务访问点来支持。
binding - 特定端口类型的具体协议和数据格式规范的绑定。
service- 相关服务访问点的集合
port - 定义为协议/数据格式绑定与具体Web访问地址组合的单个服务访问点。
1、文档结构
<definitions>
<types>
<schema>
<element>
</types> <message>
<part>
</message> <portType>
<operation>
<input>
<output>
</portType> <binding>
<operation>
<input>
<output>
</binding> <service>
<port>
<address>
</service>
</definitions>
2、文档详解
http://127.0.0.1:8989/test-webservice/hellows?wsdl文件详解
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://ws.test.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://ws.test.com/"
name="HelloWSImplService">
<!--
types
schema : 定义了一些标签结构
-->
<types>
<xsd:schema>
<!-- 此处引用的sehemaLocation地址,可以使用浏览器打开,获取schema约束 -->
<xsd:import namespace="http://ws.test.com/"
schemaLocation="http://127.0.0.1:8989/test-webservice/hellows?xsd=1"></xsd:import>
</xsd:schema>
</types> <!--
message : 用于定义消息的结构 soap消息
part :指定引用types中定义的标签片段
-->
<message name="sayHello">
<part name="parameters" element="tns:sayHello"></part>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"></part>
</message> <!--
portType : 用来定义服务器端的SEI
operation : 用来指定SEI中处理请求的方法
input : 指定客户端应用传过来的数据,会引用上面的定义的<message>
output : 指定服务器端返回给客户端的数据,会引用上面定义的<message>
-->
<portType name="HelloWSImpl">
<operation name="sayHello">
<input wsam:Action="http://ws.test.com/HelloWSImpl/sayHelloRequest" message="tns:sayHello"></input>
<output wsam:Action="http://ws.test.com/HelloWSImpl/sayHelloResponse" message="tns:sayHelloResponse"></output>
</operation>
</portType> <!--
binding : 用于定义SEI的实现类
type属性:引用上面的<portType>
<soap:binding style="document"> :绑定的数据是一个document(xml)
operation : 用来定义实现的方法
<soap:operation style="document" /> 传输的是document(xml)
input : 指定客户端引用传过来的数据
<soap:body use="literal"> :文本数据
output : 指定服务端返回给客户端的数据
<soap:body use="literal"> :文本数据
-->
<binding name="HelloWSImplPortBinding" type="tns:HelloWSImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
<operation name="sayHello">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding> <!--
service : 一个webservice的容器
name属性 : 它用已指定客户端容器类
port : 用来指定一个服务器端处理请求的入口(就是SEI的实现)
binding属性 : 引用上面定义的<binding>
address : 当前webservice的请求地址
-->
<service name="HelloWSImplService">
<port name="HelloWSImplPort" binding="tns:HelloWSImplPortBinding">
<soap:address location="http://127.0.0.1:8989/test-webservice/hellows"></soap:address>
</port>
</service>
</definitions>
引用的http://127.0.0.1:8989/test-webservice/hellows?xsd=1, schema约束如下:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.4-b01. -->
<!--
shecma约束 用于请求:
<sayHello>
<arg0>string</arg0>
</sayHello> 用于响应:
<sayHelloResponse>
<return>string</return>
</sayHelloResponse> -->
<xs:schema xmlns:tns="http://ws.test.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0"
targetNamespace="http://ws.test.com/"> <xs:element name="sayHello" type="tns:sayHello"/> <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/> <xs:complexType name="sayHello">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType> <xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
3、文档图解图

注:可以通过查看webservice的请求消息和响应消息(【WebService】使用JDK开发WebService(二)--》使用JDK开发WebService--》a、开发WebService服务端--》7、查看发送消息和响应消息的具体内容),来与wsdl文件中的message进行相互验证
【WebService】WebService之WSDL文档深入分析(三)的更多相关文章
- WSDL文档深入分析
借助jdk的wsimort.exe工具生成客户端代码 格式:wsimport -keep url //url为wsdl文件的路径 直接生成客户端代码会抛异常, 无法生成客户端代码, 解决办法: 将 ...
- WSDL 文档解析
学习webservice,就离不了WSDL文档,他是我们开发WebService的基础,虽说,现在现在有许多WebService的开源框架使得我们可以根据WSDL生成客户端代码,但是,了解WSDL文档 ...
- webservice学习01:wsdl文档结构
webservice学习01:wsdl文档结构 wsdl文档结构 WSDL文档示例 <wsdl:definitions xmlns:xsd="http://www.w3.org/200 ...
- (二)发布第一个WebService服务与DSWL文档解析
1. 编写接口 package service; import javax.jws.WebService; /** * 第一个webservice服务, * @WebService注解表示这是一个we ...
- 【Web Service】WSDL文档
WSDL文档仅仅是一个简单的XML文档. 它包含一系列描述某个web service的定义. WSDL WSDL 是基于 XML 的语言,用于描述 Web services 以及如何访问它们. WSD ...
- 利用wsdl.exe自动将wsdl文档转换为C#代码
1.获取完整的wsdl文档 获取下面这个博客中提到的wsdl http://www.cnblogs.com/LCCRNblog/p/3716406.html 将获取到的wsdl放到一个文本中,改后缀( ...
- WSDL 文档-一个简单的 XML 文档
WSDL 文档是利用这些主要的元素来描述某个 web service 的: <portType>-web service 执行的操作 <message>-web service ...
- 一个完整的WSDL文档及各标签详解
<?xml version="1.0" encoding="UTF8" ?> <wsdl:definitions targetNamespac ...
- PHP生成word文档的三种实现方式
PHP生成word原理 利用windows下面的 com组件 利用PHP将内容写入doc文件之中 具体实现: 利用windows下面的 com组件 原理:com作为PHP的一个扩展类,安装过offic ...
随机推荐
- linux 升级python2.7
linux为centos6,系统默认安装了python2.6,需要执行的python脚本内容包含标准库之xml.etree.ElementTree 用到库里的一个iter方法是python2.7的新 ...
- jquery mobil 和页面适应
<meta name="viewport" content="width=device-width" />
- idea插件推荐
CodeGlance 类似SublimeText的Mini Map插件 Background Image Plus 这又是一款装备B插件了,想想别人看到你的IDE有个美女或者异次元背景是怎样的,安装 ...
- 算法篇【递归2 -- N皇后问题】
问题:输入整数N,要求在N*N的棋盘上,互相不能攻击,不在同一行同一列上,切不在对角线上,输出全部方案. 输入: 4 输出: 2 4 1 3 3 1 4 2 思路: 假设在前k-1个摆好的 ...
- Vue之组件
Vue之全局组件 全局组件可以被任何局部组件调用 <div id="app"> <!--这里是组件的使用--> <global-component&g ...
- 第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛----随手记录帖
这是跟学长学姐组队来打的最爽的一次比赛了,也可能是互相组队最后一次比赛了,南哥和楼学姐,省赛之后就退役了,祝他们能考研和面试都有happy ending! 虽然最后没有把F题的n^2约数的数学题写完, ...
- QT各模块
基本模块: QT core QT gui QT widgets QT multimedia QT webkit 浏览器引擎 QT network QT sql QT test 单元测试 QT webv ...
- vue 实现多选
v-model <template> <!--用户页面-选择关注--> <div class="follow"> <h4>选择关注& ...
- privilege instruction error
检查新建的回调函数是否用了__stdcall修饰
- crm作业知识点集合[二]
知识点1 前面我们实现了这个功能,就是在models中如果有了choice选项,我们可以实现在页面显示这个chocice的value值,而不是key值,我们这个知识点就是在优化一下这个点 首先如果表中 ...