zoukankan      html  css  js  c++  java
  • WSDL入门

    WSDL: 网络服务描述语言, 是Web Service的描述语言,它全名:
    Web Services Description Language,是一门基于 XML 的语言,用于描述 Web Services 以及如何对它们进行访问。

    1、什么是 WSDL?

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

    2、WSDL文档结构

    WSDL 文档是利用这些主要的元素来描述某个 web service 的:

    一个 WSDL 文档的主要结构是类似这样的:

      WSDL 文档可包含其它的元素,比如 extension 元素,以及一个 service 元素,此元素可把若干个 web services 的定义组合在一个单一的 WSDL 文档中。

      WSDL端口: 

    <portType> 元素是最重要的 WSDL 元素。 

    它可描述一个 web service可被执行的操作,以及相关的消息。 

    可以把 <portType> 元素比作传统编程语言中的一个函数库(或一个模块、或一个类)。

     

       WSDL消息:

      <message> 元素定义一个操作的数据元素。

      每个消息均由一个或多个部件组成。可以把这些部件比作传统编程语言中一个函数调用的参数。

      WSDL types

      <types> 元素定义 web service 使用的数据类型。

      为了最大程度的平台中立性,WSDL 使用 XML Schema 语法来定义数据类型。

      WSDL Bindings

      <binding> 元素为每个端口定义消息格式和协议细节。

      WSDL实例: 

    <message name="getTermRequest">
       <part name="term" type="xs:string"/>
    </message>
    
    <message name="getTermResponse">
       <part name="value" type="xs:string"/>
    </message>
    
    <portType name="glossaryTerms">
      <operation name="getTerm">
            <input message="getTermRequest"/>
            <output message="getTermResponse"/>
      </operation>
    </portType>

    在这个例子中,<portType> 元素把 "glossaryTerms" 定义为某个端口的名称,把 "getTerm" 定义为某个操作的名称。

    操作 "getTerm" 拥有一个名为 "getTermRequest" 的输入消息,以及一个名为 "getTermResponse" 的输出消息。

    <message> 元素可定义每个消息的部件,以及相关联的数据类型。

    对比传统的编程,glossaryTerms 是一个函数库,而 "getTerm" 是带有输入参数 "getTermRequest" 和返回参数 getTermResponse 的一个函数。

     

    3、WSDL端口

      WSDL 端口可描述由某个 web service 提供的界面(合法操作)。

    操作类型:

    请求-响应是最普通的操作类型,不过 WSDL 定义了四种类型:

     

    4、WSDL绑定

      WSDL 绑定可为 web service 定义消息格式和协议细节。

      绑定到SOAP

    <message name="getTermRequest">
      <part name="term" type="xs:string"/>
    </message>

    <message name="getTermResponse">
      <part name="value" type="xs:string"/>
    </message>

    <portType name="glossaryTerms">
      <operation name="getTerm">
        <input message="getTermRequest"/>
        <output message="getTermResponse"/>
      </operation>
    </portType>

    <binding type="glossaryTerms" name="b1">
       <soap:binding style="document"
       transport="http://schemas.xmlsoap.org/soap/http" />
       <operation>
         <soap:operation soapAction="http://example.com/getTerm"/>
         <input><soap:body use="literal"/></input>
         <output><soap:body use="literal"/></output>
      </operation>
    </binding>

      
      binding元素有两个属性,分别为name和type属性

    name 属性定义 binding 的名称,而 type 属性指向用于 binding 的端口,在这个例子中是 "glossaryTerms" 端口。

    soap:binding 元素有两个属性 - style 属性和 transport 属性。

    style 属性可取值 "rpc" 或 "document"。在这个例子中我们使用 document。transport 属性定义了要使用的 SOAP 协议。在这个例子中我们使用 HTTP。

    operation 元素定义了每个端口提供的操作符。

    对于每个操作,相应的 SOAP 行为都需要被定义。同时您必须如何对输入和输出进行编码。在这个例子中我们使用了 "literal"。



  • 相关阅读:
    Laravel 学习笔记之文件上传
    Composer学习
    Laravel 学习笔记之数据库操作——Eloquent ORM
    PHP至Document类操作 xml 文件
    使用promise构建一个向服务器异步数据请求
    遍历DOM树
    关于tp验证码模块
    layui 封装自定义模块
    js进阶之路,关于UI资源的优化(转载)
    关于js 重载
  • 原文地址:https://www.cnblogs.com/yu2000/p/7210126.html
Copyright © 2011-2022 走看看