WSDL结构简单分析
- 格式:docx
- 大小:46.79 KB
- 文档页数:5
WSDL简单分析定义WSDL是网络服务描述语言Web Services Description Language的缩写,是一个用来描述Web服务和说明如何与Web服务通信的XML语言。
为用户提供详细的接口说明书。
∙WSDL 使用 XML 编写∙WSDL 是一种 XML 文档∙WSDL 用于描述网络服务∙WSDL 也可用于定位网络服务∙WSDL 还不是 W3C 标准功能WSDL既是机器可阅读的,又是人可阅读的。
一些最新的开发工具既能根据Web service生成WSDL文档,又能导入WSDL文档,生成调用相应Web service的代码。
(接口规范、系统概要设计说明书机器不可读)WSDL和SOAP:WSDL被设计成可以绑定除SOAP以外的其他协议,这里我们主要关注WSDL 在HTTP上和SOAP的关系。
∙业务之间将通过交换 WSDL 文件来理解对方的服务∙WSDL 绑定到SOAP以被调用∙通过HTTP(SMTP)进行传输WSDL元素WSDL 文件包含以下元素:Type:使用某种语法(如 XML 模式)的数据类型定义(string、int)Message:要传递的数据Part:消息参数Operation:服务支持的操作的抽象描述Port Type:一个或多个端点支持的操作的抽象集。
Binding:特定端口类型的具体协议和数据格式规范Port:绑定和网络地址的组合Service:相关端点的集合,包括其关联的接口、操作、消息等WSDL文档结构WSDL文档可以分为两部分。
顶部分由抽象定义组成,而底部分则由具体描述组成。
抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随机器或语言而变的元素。
这就定义了一系列服务,截然不同的网站都可以实现。
随网站而异的东西如序列化便归入底部分,因为它包含具体的定义。
l 抽象定义Types 独立与机器和语言的类型定义Messages包括函数参数(输入与输出分开)或文档描述PortTypes引用消息部分中消息定义来描述函数签名(操作名、输入参数、输出参数)2 具体定义Bindings PortTypes部分的每一操作在此绑定实现Services确定每一绑定的端口地址WSDL元素间的联系Messages栏使用Types栏的定义,PortTypes栏使用Messages栏的定义;Bindings栏引用了PortTypes栏,Services栏引用Bindings栏,PortTypes和Bindings栏包含了operation元素,而Services栏包含了port元素。
PortTypes 栏里的operation元素由Bindings栏里的operation元素进一步修改或描述。
可以借助传统编程语言来进行理解:<portType> 元素类似传统编程语言中的一个模块、或一个类,每个类包含很多方法∙<Operation> 相当于一个函数、或方法,每个方法有输入、输出值∙<Message> 输入、输出值在wsdl被称为消息Message∙<Type>输入、输出值的数据类型,如int、string实例URL:http://10.142.59.178:7001/sggis/services/CsConnectionService?wsdl <?xml version="1.0" encoding="UTF-8" ?>-<wsdl:definitions targetNamespace=""xmlns:tns=""xmlns:wsdlsoap="/wsdl/soap/"xmlns:soap12="/2003/05/soap-envelope"xmlns:xsd="/2001/XMLSchema"xmlns:soapenc11="/soap/encoding/"xmlns:soapenc12="/2003/05/soap-encoding"xmlns:soap11="/soap/envelope/"xmlns:wsdl="/wsdl/">-<wsdl:types>-<xsd:schema xmlns:xsd="/2001/XMLSchema"attributeFormDefault="qualified"elementFormDefault="qualified"targetNamespace="">-<xsd:element name="getCSConnection">-<xsd:complexType>-<xsd:sequence><xsd:element maxOccurs="1"minOccurs="1"name="username"nillable="true"type="xsd:string" /><xsd:element maxOccurs="1"minOccurs="1"name="password"nillable="true"type="xsd:string" /></xsd:sequence></xsd:complexType></xsd:element>-<xsd:element name="getCSConnectionResponse">-<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></wsdl:types>-<wsdl:message name="getCSConnectionResponse"><wsdl:part name="parameters" element="tns:getCSConnectionResponse" /> </wsdl:message>-<wsdl:message name="getCSConnectionRequest"><wsdl:part name="parameters" element="tns:getCSConnection" /> </wsdl:message>-<wsdl:portType name="CsConnectionServicePortType">-<wsdl:operation name="getCSConnection"><wsdl:input name="getCSConnectionRequest"message="tns:getCSConnectionRequest" /><wsdl:output name="getCSConnectionResponse"message="tns:getCSConnectionResponse" /></wsdl:operation></wsdl:portType>-<wsdl:binding name="CsConnectionServiceHttpBinding"type="tns:CsConnectionServicePortType"><wsdlsoap:binding style="document"transport="/soap/http" />-<wsdl:operation name="getCSConnection"><wsdlsoap:operation soapAction="" />-<wsdl:input name="getCSConnectionRequest"><wsdlsoap:body use="literal" /></wsdl:input>-<wsdl:output name="getCSConnectionResponse"><wsdlsoap:body use="literal" /></wsdl:output></wsdl:operation></wsdl:binding>-<wsdl:service name="CsConnectionService">-<wsdl:port name="CsConnectionServiceHttpPort"binding="tns:CsConnectionServiceHttpBinding"><wsdlsoap:address location="http://10.142.59.178:7001/sggis/services/CsConnectionServic e" /></wsdl:port></wsdl:service></wsdl:definitions>。