WSDL

** 什么是 WSDL? **

  • WSDL 指网络服务描述语言
  • WSDL 使用 XML 编写
  • WSDL 是一种 XML 文档
  • WSDL 用于描述网络服务
  • WSDL 也可用于定位网络服务
  • WSDL 还不是 W3C 标准

** WSDL 可描述网络服务(Web Services)**

  • WSDL 指网络服务描述语言 (Web Services Description Language)。
  • WSDL 是一种使用 XML 编写的文档。这种文档可描述某个 Web service。它可规定服务的位置,以及此服务提供的操作(或方法)。

** WSDL文档结构 **

元素 定义
Types 数据类型定义的容器,它使用某种类型系统(一般地使用XML Schema中的类型系统)
Message 通信消息的数据结构的抽象类型化定义。使用Types所定义的类型来定义整个消息的数据结构
Operation 对服务中所支持的操作的抽象描述,一般单个Operation描述了一个访问入口的请求/响应消息对
PortType 对于某个访问入口点类型所支持的操作的抽象集合,这些操作可以由一个或多个服务访问点来支持
Binding 特定端口类型的具体协议和数据格式规范的绑定。
Service 相关服务访问点的集合

** WSDL文档 **

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.zlb.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWSService" targetNamespace="http://service.zlb.com/">
 <!-- types -->
  <wsdl:types>
    <!-- 定义 schema 约束   自己引用自己定义的约束 方便下面的应用  tns:命名 -->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service.zlb.com/" elementFormDefault="unqualified" targetNamespace="http://service.zlb.com/" version="1.0">
    <xs:element name="sayHello" type="tns:sayHello"/>
    <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
    <!-- 复合类型  -->
    <xs:complexType name="sayHello">  <!-- 方法名 -->
        <xs:sequence>
          <xs:element minOccurs="0" name="arg0" type="xs:string"/><!-- 参数 以及参数的类型 -->
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="sayHelloResponse">
        <xs:sequence>
          <xs:element minOccurs="0" name="return" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  
  <!-- message -->
  <!-- 定义消息 -->
  <wsdl:message name="sayHelloResponse">  <!-- 响应消息 -->
    <wsdl:part element="tns:sayHelloResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>  
  <wsdl:message name="sayHello">  <!-- 请求消息 -->
    <wsdl:part element="tns:sayHello" name="parameters">
    </wsdl:part>
  </wsdl:message>
  
  <!-- portType -->
  <!-- 用来定义接口 -->
  <wsdl:portType name="helloWS">
    <wsdl:operation name="sayHello"> <!-- 用来指定处理请求的方法 -->
      <wsdl:input message="tns:sayHello" name="sayHello">  <!-- 指定客户端传过来的数据 引用上面定义的message -->
      </wsdl:input>
      <wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse">  <!-- 指定服务器端返回的数据 引用上面定义的message -->
      </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  
  <!-- wsdl:binding -->
  <!-- 用来定义实现类 -->
  <wsdl:binding name="HelloWSServiceSoapBinding" type="tns:helloWS"> <!-- type 引用上面的portType -->
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <!-- 指定样式为 XML格式的数据 -->
    <wsdl:operation name="sayHello"> <!-- operation 定义实现类的方法 -->
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="sayHello">
        <soap:body use="literal"/>  <!-- 指定客户端传过来的数据  基于文本形式 -->
      </wsdl:input>
      <wsdl:output name="sayHelloResponse">
        <soap:body use="literal"/>  <!-- 指定服务器返回给客户端的数据  基于文本形式 -->
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  
  <!-- wsdl:service -->
  <!-- 发布出去 并指定地址 -->
  <wsdl:service name="HelloWSService">
    <wsdl:port binding="tns:HelloWSServiceSoapBinding" name="helloWSPort"><!-- 引用 binding -->
      <soap:address location="http://127.0.0.1:8989/WebServices_service/helloWS"/> <!-- 地址 -->
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

这个WSDL的结构需要按照从下面往上面的顺序看

WSDL相关文章:<a href="http://blog.csdn.net/etttttss/article/details/17303315">WSDL详解</a>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,695评论 19 139
  • 简介 WSDL(网络服务描述语言,Web Services Description Language)是一门基于 ...
    廖马儿阅读 1,752评论 0 0
  • php处理wsdl Date:2016-09-26 19:39:30 By:0x584A 0x00 前言 近期一直...
    0x584A阅读 2,066评论 0 0
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 34,843评论 18 399
  • 乔任梁的离开轰炸了朋友圈,一开始得知是无法相信, 第二天一早消息经过确实 ,仍是无法相信 ,无法相信一个年轻生命的...
    2b4610e988d5阅读 302评论 0 1

友情链接更多精彩内容