最近项目中需要将原来的通信协议改成webservice,由于业务需要,我们需要向server端传送数据,故server方提供给我们一个.wsdl文件,内容如下:

WSDL即Web Services Description Language

<?xml version="1.0" encoding="UTF-8" ?>
<definitions targetNamespace="http://www.zhukejia.com"
 xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"
 xmlns:tns="http://www.zhukejia.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
 <types>
  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   attributeFormDefault="qualified" elementFormDefault="qualified"
   targetNamespace="http://www.zhukejia.com">
   <xsd:element name="getReader">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element maxOccurs="1" minOccurs="1" name="in0"
       nillable="true" type="xsd:string" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
   <xsd:element name="getReaderResponse">
    <xsd:complexType>
     <xsd:sequence>
      <xsd:element maxOccurs="1" minOccurs="1" name="out"
       nillable="true" type="xsd:string" />
     </xsd:sequence>
    </xsd:complexType>
   </xsd:element>
  </xsd:schema>
 </types>
 <message name="getReaderRequest">
  <part name="parameters" element="tns:getReader" />
 </message>
 <message name="getReaderResponse">
  <part name="parameters" element="tns:getReaderResponse" />
 </message>
 <portType name="CallRequsetPortType">
  <operation name="getReader">
   <input name="getReaderRequest" message="tns:getReaderRequest" />
   <output name="getReaderResponse" message="tns:getReaderResponse" />
  </operation>
 </portType>
 <binding name="CallRequsetHttpBinding" type="tns:CallRequsetPortType">
  <wsdlsoap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
  <operation name="getReader">
   <wsdlsoap:operation soapAction="" />
   <input name="getReaderRequest">
    <wsdlsoap:body use="literal" />
   </input>
   <output name="getReaderResponse">
    <wsdlsoap:body use="literal" />
   </output>
  </operation>
 </binding>
 <service name="CallRequset">
  <port name="CallRequsetHttpPort" binding="tns:CallRequsetHttpBinding">
   <wsdlsoap:address location="http://132.120.115.23:7003//cxf/CallRequset" />
  </port>
 </service>
</definitions>

如文件所示,整个wsdl文件主要由红色标记的及部分组成:

一.声明

<?xml version="1.0" encoding="UTF-8" ?>

二.定义<definitions>

所有WSDL文档的根元素都是definition元素,definitions元素中一般包括若干个XML命名空间.

三. <types>

types元素用作一个容器,定义了自定义的特殊数据类型,在声明消息部分(有效负载)的时候,messages定义使用了types元素中定义的数据类型与元素。

四.<message>

Message元素描述了Web服务的有效负载。相当于函数调用中的参数和返回值。本例中对应getReaderRequest和getReaderResponse,其中每一个输入或者输出使用part元素定义

五.<portType>

<portType name="CallRequsetPortType">
  <operation name="getReader">
   <input name="getReaderRequest" message="tns:getReaderRequest" />
   <output name="getReaderResponse" message="tns:getReaderResponse" />
  </operation>
 </portType>

其中name="CallRequsetPortType"指定了Web服务的抽象接口,本例中对应的便是CallRequsetPortType.java,该接口中的抽象方法就是我们对应要实现的server端的方法。本例中对应的名字是getReader

六.<binding>

Binding元素将一个抽象的portType映射到一组具体的协议(SOAP或者HTTP)、消息传递样式(RPC或者document)以及编码样式(literal或者SOAP encoding)。
 Binding类似于将接口或者函数的调用绑定到某种协议上:例如CORBA、COM或者RPC的方式,这里使用SOAP协议。

七.<service>

Service元素包含一个或者多个Port元素

每一个Port元素对应一个不同的Web服务,port将一个URL赋予一个特定的binding,通过location实现

可以使两个或者多个port元素将不同的URL赋给相同的binding,例如负载平衡和容错的时候,使用这种方法。

wsdlsoap:address:将Internet地址通过location属性赋予一个SOAP绑定。

具体分析wsdl文件过程请参考下面截图:

另外:WSDL支持 4 种消息交换方式:(本文采用的是请求响应(Request-response))

1)单向(One-way):服务端接收消息;

2)请求响应(Request-response):服务端点接收请求消息,然后发送响应消息;

3)要求应答(Solicit-response):服务访问端发送要求消息,然后接收应答消息。

4)通知(Notification):服务访问端点发送通知消息。

webservice之wsdl的更多相关文章

  1. [Java] webservice soap,wsdl 例子

    java 调用webservice的各种方法总结 现在webservice加xml技术已经逐渐成熟,但要真正要用起来还需时日!! 由于毕业设计缘故,我看了很多关于webservice方面的知识,今天和 ...

  2. Webservice、WSDL三种服务访问的方式【转】

    http://www.cnblogs.com/yongfeng/archive/2013/01/30/2883146.html 用soapUI试了下wsdl的测试,但还是不知道webService和W ...

  3. 浅淡Webservice、WSDL三种服务访问的方式(附案例)

    Webservice Webservice是使应用程序以与平台和编程语言无关的方式进行相互通信技术. eg:站点提供访问的数据接口:新浪微博.淘宝. 官方解释:它是一种构建应用程序的普遍模型,可以在任 ...

  4. webservice接口测试wsdl,参数是xml格式。python,入参转化成str,返回值转化成dict调用

    1.用SoapUI测试webservice接口,传入参数是xml格式时.xml格式需要将xml的外围增加<![CDATA[xml]]> 2.但是用python去做webservice测试, ...

  5. delphi 调用Webservice 引入wsdl 报错 document empty

    delphi 调用Webservice 引入wsdl 报错 document empty 直接引入wsdl 地址报错 document empty 解决办法:在浏览器里保存为xml文件,然后在开发环境 ...

  6. cxf webservice 生成wsdl方法参数名称为arg0问题

    在通过cxf生成webservice服务时,如果你是用ServerFactoryBean,那么在生成wsdl时,方法的参数名称会被自动命名为arg0,arg1...,如: <xsd:comple ...

  7. cxf WebService设置wsdl中soapAction的值

    用cxf开发一个WebService很简单,只需要下面几步: 1.定义接口 public interface HelloService { String hello(); } 2.实现 public ...

  8. 彻底理解webservice SOAP WSDL

    WebServices简介 先给出一个概念 SOA ,即Service Oriented Architecture ,中文一般理解为面向服务的架构, 既然说是一种架构的话,所以一般认为 SOA 是包含 ...

  9. 理解WebService SOAP WSDL

    WebServices简介 先给出一个概念 SOA ,即Service Oriented Architecture ,中文一般理解为面向服务的架构, 既然说是一种架构的话,所以一般认为 SOA 是包含 ...

  10. webservice 的wsdl文件生成客户端java类

    提供两个方法: 第一个: 发布webservice项目后, 地址栏地址  http://localhost:8888/lxitedu.webservice.cxf-ch2/services/userS ...

随机推荐

  1. UVa 10382 喷水装置(贪心)

    https://vjudge.net/problem/UVA-10382 题意: 有一个长为l,宽为w的草坪,在其中心线不同位置有n个点状的喷水装置,喷水坐标为p,喷水半径为r.求喷到所有草坪的最少喷 ...

  2. python 删除元组元素

    #create a tuple tuplex = "w", "j" ,"c", "e" print(tuplex) #t ...

  3. python 无序表查找

    def sequential_search(lis, key): for i in range(len(lis)): if(lis[i] == key): return i else: return ...

  4. [ios]关于ios开发图片尺寸的建议

    1.以后的应用程序,都使用AutoLayout, 不要再用绝对定位. 2.使用类似网页的方式来设计界面. 3.设计师好,程序员也好,尽量使用点这个单位进行思考,而不要使用像素.比如,你需要做44 x ...

  5. spring boot 开发 提交form表单出错

    提交表单时,字段有的没有值,springboot 会报错. org.springframework.validation.BindException: org.springframework.vali ...

  6. Spring AMQP 源码分析 01 - Impatient

    ### 准备   ## 目标 了解 Spring AMQP 核心代码   ## 前置知识 RabbitMQ 入门   ## 相关资源   Quick Tour for the impatient:&l ...

  7. /var/run/dbus/system_bus_socket no such file or directory

    参考:http://fixmyos.blogspot.jp/2011/10/failed-to-connect-to-socket.html /var/run/dbus/system_bus_sock ...

  8. 20170814xlVBA部分代号收盘价转置

    原始数据: 转置效果: Sub TransformData() Dim Rng As Range Dim Arr As Variant Dim Dic As Object Dim dCode As O ...

  9. 12月17日周日 form_for的部分理解。belongs_to的部分理解

    1.lean guide:helper method query ,✅

  10. Confluence 6 LDAP 高级设置

    启用嵌套组(Enable Nested Groups) 为嵌套组启用或禁用支持. 一些目录服务器能够允许你在一个组中定义另外一个组.在这种结构下的用户组称为用户组嵌套.嵌套组的配置能够让子用户组继承上 ...