转 wsdl
2015-08-08 11:19
357 查看
WSDL是web service标准当中描述语言,服务器端通过wsdl可以描述发布的服务,客户端通过获取服务端提供的wsdl了解服务器端,以便调用服务器端提供的服务。
下面分段了解一下wsdl的详细描述吧。我们通过一个搜索方法来描述,该方法提供输入搜索字段和搜索关键字,分别是String类型的。返回结果是一个结果集,用List类型保存。我们按照上面的表格来一个个的分析下WSDL的构成。
<service>元素描述
Xml代码
<wsdl:service name="SimpleSearch_Server">
<wsdl:port name="SimpleSearch_ServerHttpPort" binding="tns:SimpleSearch_ServerHttpBinding">
<wsdlsoap:address location="http://localhost:8080/Patent_Demo/services/SimpleSearch_Server" />
</wsdl:port>
</wsdl:service>
1. 申明该服务的名称是SimpleSearch_Server
2. Binding表示需要绑定的通信协议是什么,绑定到wsdl当中的binding元素,这里指定到SimpleSearch_ServerHttpBinding当中。
3. 申明提供的服务地址是:
http://localhost:8080/Patent_Demo/services/SimpleSearch_Server通过访问 http://localhost:8080/Patent_Demo/services/SimpleSearch_Server?wsdl可以查看wsdl信息
<binding>元素描述
Xml代码
<wsdl:binding name="SimpleSearch_ServerHttpBinding" type="tns:SimpleSearch_ServerPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="search">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="searchRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="searchResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
1. 申明该binding名称是SimpleSearch_ServerHttpBinding
2. 指定该binding指定的操作元素为tns:SimpleSearch_ServerPortType
3. 该服务提供search方法,并具有request-response模式。消息传递类型为literal
<Port-type>元素描述
Xml代码
<wsdl:portType name="SimpleSearch_ServerPortType">
<wsdl:operation name="search">
<wsdl:input name="searchRequest" message="tns:searchRequest" />
<wsdl:output name="searchResponse" message="tns:searchResponse" />
</wsdl:operation>
</wsdl:portType>
1. 定义提供search方法
2. 定义request-response模式,并制定消息类型为searchRequest和searchResponse
<message>元素描述
Xml代码
<wsdl:message name="searchResponse">
<wsdl:part name="parameters" element="tns:searchResponse" />
</wsdl:message>
<wsdl:message name="searchRequest">
<wsdl:part name="parameters" element="tns:search" />
</wsdl:message>
1. 对应port-type当中的消息类型,以searchResponse为例,当用户发送请求的时候,定义请求参数类型为search
2. searchResponse当中定义了当请求处理完毕向用户返回参数的类型为searchResponse。两者都对应到<type>元素当中
<type>元素描述
<wsdl:types>
Xml代码
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.ws.patent.com">
<xsd:element name="search">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="string" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="searchResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="tns:ArrayOfString" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
1. search类型对应message消息当中请求消息类型,searchResponse同样如此。
2. search当中定义请求的第0,1个参数分别用String类型表示
3. searchResponse中定义返回以几何形式(ArrayofString)类型。ArrayofString在type元素当中也有定义,表示由String组成的类型组成
元素 | 定义 |
<portType> | web service 执行的操作 |
<message> | web service 使用的消息 |
<types> | web service 使用的数据类型 |
<binding> | web service 使用的通信协议 |
<service> | web service 使用的服务名称和地址 |
<service>元素描述
Xml代码
<wsdl:service name="SimpleSearch_Server">
<wsdl:port name="SimpleSearch_ServerHttpPort" binding="tns:SimpleSearch_ServerHttpBinding">
<wsdlsoap:address location="http://localhost:8080/Patent_Demo/services/SimpleSearch_Server" />
</wsdl:port>
</wsdl:service>
1. 申明该服务的名称是SimpleSearch_Server
2. Binding表示需要绑定的通信协议是什么,绑定到wsdl当中的binding元素,这里指定到SimpleSearch_ServerHttpBinding当中。
3. 申明提供的服务地址是:
http://localhost:8080/Patent_Demo/services/SimpleSearch_Server通过访问 http://localhost:8080/Patent_Demo/services/SimpleSearch_Server?wsdl可以查看wsdl信息
<binding>元素描述
Xml代码
<wsdl:binding name="SimpleSearch_ServerHttpBinding" type="tns:SimpleSearch_ServerPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="search">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="searchRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="searchResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
1. 申明该binding名称是SimpleSearch_ServerHttpBinding
2. 指定该binding指定的操作元素为tns:SimpleSearch_ServerPortType
3. 该服务提供search方法,并具有request-response模式。消息传递类型为literal
<Port-type>元素描述
Xml代码
<wsdl:portType name="SimpleSearch_ServerPortType">
<wsdl:operation name="search">
<wsdl:input name="searchRequest" message="tns:searchRequest" />
<wsdl:output name="searchResponse" message="tns:searchResponse" />
</wsdl:operation>
</wsdl:portType>
1. 定义提供search方法
2. 定义request-response模式,并制定消息类型为searchRequest和searchResponse
<message>元素描述
Xml代码
<wsdl:message name="searchResponse">
<wsdl:part name="parameters" element="tns:searchResponse" />
</wsdl:message>
<wsdl:message name="searchRequest">
<wsdl:part name="parameters" element="tns:search" />
</wsdl:message>
1. 对应port-type当中的消息类型,以searchResponse为例,当用户发送请求的时候,定义请求参数类型为search
2. searchResponse当中定义了当请求处理完毕向用户返回参数的类型为searchResponse。两者都对应到<type>元素当中
<type>元素描述
<wsdl:types>
Xml代码
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.ws.patent.com">
<xsd:element name="search">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
<xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="string" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="searchResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="tns:ArrayOfString" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
1. search类型对应message消息当中请求消息类型,searchResponse同样如此。
2. search当中定义请求的第0,1个参数分别用String类型表示
3. searchResponse中定义返回以几何形式(ArrayofString)类型。ArrayofString在type元素当中也有定义,表示由String组成的类型组成
相关文章推荐
- UIWebView网页视图—IOS开发
- volatile 关键字
- HDU - 3466 Proud Merchants(不理解)
- kali无法输入中文
- Cent OS下发送邮件
- eclipse如何查看类之间的引用关系
- onfiguration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
- 如何生成vfh特征值pcd文件
- 理解Linux的硬连接与软连接
- 南邮 OJ 2097 2_A+B(II)
- shell中截取cut所不能做好的字符串的方法
- Java中字符串为什么不以\0结尾
- Python安装.whl包的一系列问题
- LAMP开发环境的搭建
- leetcode 84: Largest Rectangle in Histogram
- 分数相加减的代码(c++)
- Objective-C 基础一:面向对象过程基础知识
- 微信本地调试、ngrok、tunnel
- 站长工具权重评定标准
- Tcl学习之--流程控制|过程