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文档深入分析(三)的更多相关文章

  1. WSDL文档深入分析

    借助jdk的wsimort.exe工具生成客户端代码 格式:wsimport -keep url   //url为wsdl文件的路径 直接生成客户端代码会抛异常, 无法生成客户端代码, 解决办法: 将 ...

  2. WSDL 文档解析

    学习webservice,就离不了WSDL文档,他是我们开发WebService的基础,虽说,现在现在有许多WebService的开源框架使得我们可以根据WSDL生成客户端代码,但是,了解WSDL文档 ...

  3. webservice学习01:wsdl文档结构

    webservice学习01:wsdl文档结构 wsdl文档结构 WSDL文档示例 <wsdl:definitions xmlns:xsd="http://www.w3.org/200 ...

  4. (二)发布第一个WebService服务与DSWL文档解析

    1. 编写接口 package service; import javax.jws.WebService; /** * 第一个webservice服务, * @WebService注解表示这是一个we ...

  5. 【Web Service】WSDL文档

    WSDL文档仅仅是一个简单的XML文档. 它包含一系列描述某个web service的定义. WSDL WSDL 是基于 XML 的语言,用于描述 Web services 以及如何访问它们. WSD ...

  6. 利用wsdl.exe自动将wsdl文档转换为C#代码

    1.获取完整的wsdl文档 获取下面这个博客中提到的wsdl http://www.cnblogs.com/LCCRNblog/p/3716406.html 将获取到的wsdl放到一个文本中,改后缀( ...

  7. WSDL 文档-一个简单的 XML 文档

    WSDL 文档是利用这些主要的元素来描述某个 web service 的: <portType>-web service 执行的操作 <message>-web service ...

  8. 一个完整的WSDL文档及各标签详解

    <?xml version="1.0" encoding="UTF8" ?> <wsdl:definitions targetNamespac ...

  9. PHP生成word文档的三种实现方式

    PHP生成word原理 利用windows下面的 com组件 利用PHP将内容写入doc文件之中 具体实现: 利用windows下面的 com组件 原理:com作为PHP的一个扩展类,安装过offic ...

随机推荐

  1. 有人说,即使没有JavaScript,你也可以做网页。在纯HTML

    有人说,即使没有JavaScript,你也可以做网页.在纯HTML +服务器端语言理论中也可以完成所有功能,那么,为什么以及在哪里存在JavaScript?   JS,全称JavaScript   在 ...

  2. 枚举+最短路 poj1062

    这里有个非常坑的地方,还有比酋长地位还更高的人,我也是看了论坛才知道... 在这里我把编号1看成终点,优惠价格看成相应的替代品编号到可替代品编号的权值,比如说有了2再加8000就到了1,那么2到1的弧 ...

  3. Android 基础 (四大组件,五大存储,六大布局)

    Android四大组件: 参考:https://blog.csdn.net/shenggaofei/article/details/52450668 Android四大组件分别为activity.se ...

  4. Shell教程 之函数

    1.函数定义 shell中函数的定义格式如下: [ function ] funname [()] { action; [return int;] } 说明: 可以带function fun() 定义 ...

  5. Shell教程 之运算符

    1.Shell基本运算符 Shell 和其他编程语言一样,支持多种运算符,包括: 算数运算符: 关系运算符: 布尔运算符: 字符串运算符: 文件测试运算符. 原生bash不支持简单的数学运算,但是可以 ...

  6. Cisco VSS

    1.原理 VSS是将两台及以上的物理设备虚拟成逻辑上的一台,可类比堆叠.VSS在控制层面上两个交换机有主从之分,但在数据面上处理是双活的.无论是从网络控制层面和管理视图上在网络上都是一个单独的设备实体 ...

  7. c#: Noto Sans字体如何支持韩文

    1.源起: VCU10项目,使用了Noto Sans字体,的确漂亮.但验证在win7下,其显示韩文为乱码,颇为头痛. 其界面显示如图: 度娘之,得Noto Sans又有CJK字体,顾名思义,其为支持中 ...

  8. python之集合【set】

    初学python,今天晚上学习了set,做下set的总结,set的中文名也就是[集合],set的总结分为两部分,第一部分是set的创建,第二部分是set的操作,也就是set的功能:set的特点是无序的 ...

  9. 关于viewport我自己的理解

    其实即使不在html中添加meta viewport标签,每个移动端浏览器都会有一个默认的viewport,只是这个viewport的宽度是980,然后做1:3或者1:2的自动缩放.所以当不在html ...

  10. window10安装黑苹果

    一位大佬的分享笔记 启动盘https://github.com/Macrow/Hactonish clover的下载地址https://sourceforge.net/projects/clovere ...