【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 ...
随机推荐
- 机器人编程挑战python
机器人编程挑战 要使用pip安装模拟器,请运行pip install zombiedice(在Windows上)或pip3 install zombiedice(在macOS和Linux上).要使用一 ...
- mysql5.7.20更改root密码
my.cnf 中在[mysqld]下面增加 skip-grant-tables 使用空密码登录数据库执行下面命令 update mysql.user set authentication_string ...
- UVA-816.Abbott's Tevenge (BFS + 打印路径)
本题大意:给定一个迷宫,让你判断是否能从给定的起点到达给定的终点,这里起点需要输入起始方向,迷宫的每个顶点也都有行走限制,每个顶点都有特殊的转向约束...具体看题目便知... 本题思路:保存起点和终点 ...
- IE浏览器调试工具不能使用
Mac 使用VMware Fusion虚拟机,安装Windows 7 Service Pack 1 (SP1). 移除自带的IE8,下载并安装IE11(64位). IE 11 调试工具不能使用,并且调 ...
- 问题2:input、textarea、submit 宽度设置为100%,但显示宽度不一致
<style type="text/css"> body{ padding: 10px; } input,textarea{ width: 100%; } </s ...
- iOS开发时使用的bundle路径
bundle是一个目录,其中包含了程序会使用到的资源. 这些资源包含了如图像,声音,编译好的代码,nib文件(用户也会把bundle称为plug-in). 对应bundle,cocoa提供了类NSBu ...
- Hashed collections哈希集合
[定义] 有index的集合 [hash的原理] term for a situation when two different objects return the same hashcode: h ...
- day 24 socket 黏包
socket 套接字的使用: tcp是基于链接的,必须先启动服务端,然后再启动客户端去链接服务端 server 端 import socket sk = socket.socket() # 实例化一个 ...
- 32-改变eclipse默认的Tomcat部署路径
转载:https://www.cnblogs.com/helf/p/9433588.html eclipse中默认的项目部署路径是在项目的路径,不像myeclipse那样部署后项目在Tomcat的安装 ...
- Excel上传找到错误数据类型
一:查询数据库表中字段的类型语句 SELECT CASE WHEN col.colorder = 1 THEN obj.name ELSE '' END AS 表名, col.colorder AS ...