webservice之wsdl
最近项目中需要将原来的通信协议改成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的更多相关文章
- [Java] webservice soap,wsdl 例子
java 调用webservice的各种方法总结 现在webservice加xml技术已经逐渐成熟,但要真正要用起来还需时日!! 由于毕业设计缘故,我看了很多关于webservice方面的知识,今天和 ...
- Webservice、WSDL三种服务访问的方式【转】
http://www.cnblogs.com/yongfeng/archive/2013/01/30/2883146.html 用soapUI试了下wsdl的测试,但还是不知道webService和W ...
- 浅淡Webservice、WSDL三种服务访问的方式(附案例)
Webservice Webservice是使应用程序以与平台和编程语言无关的方式进行相互通信技术. eg:站点提供访问的数据接口:新浪微博.淘宝. 官方解释:它是一种构建应用程序的普遍模型,可以在任 ...
- webservice接口测试wsdl,参数是xml格式。python,入参转化成str,返回值转化成dict调用
1.用SoapUI测试webservice接口,传入参数是xml格式时.xml格式需要将xml的外围增加<![CDATA[xml]]> 2.但是用python去做webservice测试, ...
- delphi 调用Webservice 引入wsdl 报错 document empty
delphi 调用Webservice 引入wsdl 报错 document empty 直接引入wsdl 地址报错 document empty 解决办法:在浏览器里保存为xml文件,然后在开发环境 ...
- cxf webservice 生成wsdl方法参数名称为arg0问题
在通过cxf生成webservice服务时,如果你是用ServerFactoryBean,那么在生成wsdl时,方法的参数名称会被自动命名为arg0,arg1...,如: <xsd:comple ...
- cxf WebService设置wsdl中soapAction的值
用cxf开发一个WebService很简单,只需要下面几步: 1.定义接口 public interface HelloService { String hello(); } 2.实现 public ...
- 彻底理解webservice SOAP WSDL
WebServices简介 先给出一个概念 SOA ,即Service Oriented Architecture ,中文一般理解为面向服务的架构, 既然说是一种架构的话,所以一般认为 SOA 是包含 ...
- 理解WebService SOAP WSDL
WebServices简介 先给出一个概念 SOA ,即Service Oriented Architecture ,中文一般理解为面向服务的架构, 既然说是一种架构的话,所以一般认为 SOA 是包含 ...
- webservice 的wsdl文件生成客户端java类
提供两个方法: 第一个: 发布webservice项目后, 地址栏地址 http://localhost:8888/lxitedu.webservice.cxf-ch2/services/userS ...
随机推荐
- Source not found :Edit Source Lookup Path 解决方案
作者原创,转载请注明转载地址 在eclipse中用debug调试的时候,出现了以下问题,很是尴尬,经常碰到,所以有必要进行总结一下: 对该问题有两种解决方案, 一种比较文明:解决方法可参考如下网址: ...
- python 数据交换
例1 def change(data): data[],data[]=data[],data[] print('函数内交换位置后:') ): print('data[%d]=%3d' %(i,data ...
- Springboot 学习遇到的一些错和埋坑之旅
1. java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @Cont ...
- 《剑指offer》第二十题(表示数值的字符串)
// 面试题20:表示数值的字符串 // 题目:请实现一个函数用来判断字符串是否表示数值(包括整数和小数).例如, // 字符串“+100”.“5e2”.“-123”.“3.1416”及“-1E-16 ...
- 牛客练习赛7 E 珂朵莉的数列
珂朵莉的数列 思路: 树状数组+高精度 离散化不知道哪里写错了,一直wa,最后用二分写的离散化 哪位路过大神可以帮我看看原来的那个离散化错在哪里啊 通过代码: import java.math.Big ...
- ln软连接
ln软连接 ln -s 源目录/文件 目标目录/文件 例如,有个应用 /var/www/html/webapp,下面有个logs日志文件夹,想吧 webapp/logs日志文件夹链到/home ...
- [.NET开发] C#实现剪切板功能
C#剪切板 Clipboard类 我们现在先来看一下官方文档的介绍 位于:System.Windows.Forms 命名空间下 Provides methods to place data on an ...
- [.NET开发] C# 读写文件
1.C#读文件 按行读取文件: public void Read(string path) { StreamReader sr = new StreamReader(path,Encoding.Def ...
- English trip -- VC(情景课)4 D
What do you see? I can see three men in the pictrue. one older man is a doctor, two younger men are ...
- mysql 视图,事务,存储过程,触发器
一 视图 视图是一个虚拟表(非真实存在),是跑到内存中的表,真实表是硬盘上的表.使用视图我们可以把查询过程中的临时表摘出来,保存下来,用视图去实现,这样以后再想操作该临时表的数据时就无需重写复杂的sq ...