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 ...
随机推荐
- NS3 fifth.cc 拥塞窗口实例
fifth.cc /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * This progr ...
- annovar积累
20170222 ANNOVAR简介 ANNOVAR是由王凯编写的一个注释软件,可以对SNP和indel进行注释,也可以进行变异的过滤筛选. ANNOVAR能够利用最新的数据来分析各种基因组中的遗传变 ...
- Linux——用户管理简单学习笔记(四)
主要讲两个用户管理的案例: 1: 限制用户su为root,只允许某个组的的用户su # groupadd sugroup 首先添加我们的用户组 # chmod 4550 /bin/su 改变命令的权限 ...
- Codeforces Round #323 (Div. 2) D. Once Again... 乱搞+LIS
D. Once Again... time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 哈希表-java
import java.util.HashMap; import java.util.Iterator; public class JavaHashMap { public static void m ...
- Springboot 学习笔记 之 Day 2
“约定大于配置”这样一句话,就是说系统,类库,框架应该假定合理的默认值,而非要求提供不必要的配置,可是使用Spring或者SpringMVC的话依然有许多这样的东西需要我们进行配置,这样不仅徒增工作量 ...
- Hadoop 部分截图
- Jmeter性能测试 对服务器使用资源进行监控之ServerAgent插件使用
百度云盘友情赞助地址如下: 链接:https://pan.baidu.com/s/1cpAeOcfFX8kss1eo79UD9g 密码:b8o7 在windows上或者linux上打开服务 用Jmet ...
- spring boot开发 @autowired注入失败
@autowired注入失败 会出现如下错误提示: 2018-05-28 08:39:41.857 INFO 8080 --- [ restartedMain] org.hibernate.Versi ...
- English trip V1 - 辅导课 VOCABULARY BRUSH UP(1-6) 词汇刷新 SA:Winona
1.How Do you Feel Now? 形容词 adj. = adjective Describe people and thi ...