【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 ...
随机推荐
- Jmeter使用HTTP代理服务器进行录制
1.添加一个线程组 2.在工作台右键添加HTTP代理服务器 3.配置代理服务器 *注:端口号不能被占用.排除模式中添加的东西将在录制时不被录制上. 端口可能会有被占用的情况,这种情况下点击启动会报错, ...
- Excel图表编辑---表格移动,样式修改
一.移动位置和调整大小 先鼠标选中如下面这个图片,之后点击上方的设计按钮,随后选择右边的, 再选择,就可以实现图片的表格之间的移动. 其中移动图表里面的,选中这个之后,图表的大小会根据窗口的大小自动调 ...
- hibernate中调用query.list()而出现的黄色警告线
使用hibernate的时候会用到hql语句查询数据库, 那就一定会用到query.list();这个方法, 那就一定会出现一个长长的黄色的警告线, 不管你想尽什么办法, 总是存在, 虽然说这个黄色的 ...
- Jenkins+sonar7.3集成
Jenkins安装请参考:https://blog.csdn.net/CheNorton/article/details/50327825?utm_source=copy Jenkins更新请参考:h ...
- Python memoryview() 函数
Python memoryview() 函数 Python 内置函数 描述 memoryview() 函数返回给定参数的内存查看对象(Momory view). 所谓内存查看对象,是指对支持缓冲区协 ...
- mycat配置实现mysql读写分离
需要先把mysql的主从复制配置好,然后才可以开始mycat的配置 m ysql主从复制配置:https://www.cnblogs.com/renjianjun/p/9093062.html myc ...
- 连接SQL常见问题
HTTP Status 500 – Internal Server Error Type Exception Report Message Request processing failed; nes ...
- Django的具体操作(一)
一,首先说下什么是Django,Django其实就是一个框架,用python写的,能开发网站之类的. 二,django的组成 1,urls:网址入口关联到对应的views视图函数,(采用mvc开发模式 ...
- eclipse Mars4.5.2安装fatjar
试了在eclipse下添加plugins的方法,但是并没有生效 最后看了一篇博客@参考博客 原文转载: 首先声明,eclipse luna 和mars 楼主亲测可用. .安装Eclipse2.0版本的 ...
- idea不识别yml配置文件,怎么办?
问题描述: 如下图,新建的springboot项目,添加了自定义的配置文件后,2.yml无法像上方文件的一样,被识别成配置文件! 虽然可能不会影响项目(不确定),但问题不解决,根本没有心情开始下一 ...