最近项目中需要将原来的通信协议改成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. java代码实现highchart与数据库数据结合完整案例分析(一)---饼状图

    作者原创:转载请注明出处 在做项目的过程中,经常会用到统计数据,同时会用到highchart或echart进行数据展示,highchart是外国开发的数据统计图插件, echart是我们国家开发的数据 ...

  2. org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement profile

    原创:转载请注明出处 1.异常情况 org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected ...

  3. NS3 实验脚本的编写步骤

    第一步:配置主机,安装模块 (1)创建N个节点: NodeContainer nodes; nodes.Creat(N); 比如我目前接触到的PointToPoint,N就是2 (2)利用拓扑助手He ...

  4. Springboot统一参数验证方式

    Springboot统一验证方式 在提供http api 接口形式的服务中,通过都会传递参数为一个对象.我们需要对这个对象的各个字段进行校验.来判断是否为合法值. 传统的方式为自己获取每个字段的值,自 ...

  5. 111python

    补充一句,为兼容平台文件地址可以这么写: file = os.path.join('dir', 'file_name')

  6. Python的替换函数——replace(),strip(),和re.sub()

    在Python中常用的三个"替换"函数是strip(),replace()和re.sub(),下面来讲讲这三个函数的用法. 一.replace() 基本用法:对象.replace( ...

  7. 会员通过消费攒积分,升级RENEW以及降级的需求

    需求看上去及其简单,如下: 用文字描述就开始不容易了. 先按等级排个序,根据下一个等级,推前一个等级: --C---B----V-----A 在计算一下升级需要的积分:--C表示普通会员-----需要 ...

  8. SetCommMask

    SetCommMask           用途:设置串口通信事件   原型:BOOL SetCommMask(HANDLE hFile, //标识通信端口的句柄   DWORD dwEvtMask ...

  9. vmware 安装ubuntu

    点击自定义硬件 即将完毕 下面就是安装啦

  10. 《剑指offer》第十三题(机器人的运动范围)

    // 面试题:机器人的运动范围 // 题目:地上有一个m行n列的方格.一个机器人从坐标(0, 0)的格子开始移动,它 // 每一次可以向左.右.上.下移动一格,但不能进入行坐标和列坐标的数位之和 // ...