Web Service描述语言 WSDL 详解(5)
来源:互联网 发布:apache abs.exe 编辑:程序博客网 时间:2024/04/29 13:52
XSD提供<list>结构来声明一个数组,元素之间有空格界定。不过SOAP不是使用XSD来编码数组的,它定义了自己的数组类型--"SOAP-ENC: Array"。下列的例子揭示了从这一类型派生出一位整数数组的方法:
<xsd:complexType name="ArrayOfInt">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" WSDL:arrayType="xsd:int[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
新的complex类型从soapenc:array限制派生。然后又声明了complex类型的一个属性。引用"soapenc:arrayType"实际上是这样完成的:
<xsd:attribute name="arrayType" type="xsd:string"/>
WSDL:arrayType属性值决定了数组每个成员的类型。数组的成员也可以是Complex类型。:
<xsd:complexType name="ArrayOfPERSON">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
WSDL:arrayType="typens:PERSON[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
WSDL要求数组的类型由"ArrayOf"和每个数组元素的类型串联而成。很显然,顾名思义,"ArrayOfPERSON"是PERSON结构的数组。下面我将使用ArrayOfPERSON来声明一个<message>,并加入不止一个PERSON:
<?xml version="1.0" encoding="UTF-8" ?>
<definitions … >
<types>
<schema targetNamespace="someNamespace"
xmlns:typens="someNamespace" >
<xsd:complexType name="PERSON">
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string"/>
<xsd:element name="lastName" type="xsd:string"/>
<xsd:element name="ageInYears" type="xsd:int"/>
<xsd:element name="weightInLbs" type="xsd:float"/>
<xsd:element name="heightInInches" type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ArrayOfPERSON">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType"
WSDL:arrayType="typens:PERSON[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</schema>
</types>
<message name="addPersons">
<part name="person" type="typens:ArrayOfPERSON"/>
</message>
<message name="addPersonResponse">
<part name="result" type="xsd:int"/>
</message>
</definitions>
<portType>和<operation>元素
PortType定义了一些抽象的操作。PortType中的operation元素定义了调用PortType中所有方法的语法,每一个operation元素声明了方法的名称、参数(使用<message>元素)和各自的类型(<part>元素要在所有<message>中声明)。
在一篇WSDL文档中可以有几个<PortType>元素,每一个都和一些相关操作放在一起,就和COM和一组操作的接口相似。
在<operation>元素中,可能会有至多一个<input>元素,一个<output>元素,以及一个<fault>元素。三个元素各有一个名字和一个消息属性。
<input>, <output>, <fault>元素属性的名字有何含义呢?它们可以用来区别两个同名操作(重载)。例如,看下面两个C函数:
void foo(int arg);
void foo(string arg);
这种重载在WSDL中可以这样表示:
<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="fooDescription"
targetNamespace="http://tempuri.org/WSDL/"
xmlns:WSDLns="http://tempuri.org/WSDL/"
xmlns:typens="http://tempuri.org/xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/WSDL/soap/"
xmlns:stk="http://schemas.microsoft.com/soap-toolkit/WSDL-
extension"
xmlns="http://schemas.xmlsoap.org/WSDL/">
<types>
<schema targetNamespace="http://tempuri.org/xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:WSDL="http://schemas.xmlsoap.org/WSDL/"
elementFormDefault="qualified" >
</schema>
</types>
<message name="foo1">
<part name="arg" type="xsd:int"/>
</message>
<message name="foo2">
<part name="arg" type="xsd:string"/>
</message>
<portType name="fooSamplePortType">
<operation name="foo" parameterOrder="arg " >
<input name="foo1" message="WSDLns:foo1"/>
</operation>
<operation name="foo" parameterOrder="arg " >
<input name="foo2" message="WSDLns:foo2"/>
</operation>
</portType>
<binding name="fooSampleBinding" type="WSDLns:fooSamplePortType">
<stk:binding preferredEncoding="UTF-8" />
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="foo">
<soap:operation soapAction="http://tempuri.org/action/foo1"/>
<input name="foo1">
<soap:body use="encoded" namespace="http://tempuri.org/message/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
</operation>
<operation name="foo">
<soap:operation soapAction="http://tempuri.org/action/foo2"/>
<input name="foo2">
<soap:body use="encoded"
namespace="http://tempuri.org/message/"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
</input>
</operation>
</binding>
<Service name="FOOService">
<port name="fooSamplePort" binding="fooSampleBinding">
<soap:address
location="http://carlos:8080/fooService/foo.asp"/>
</port>
</Service>
</definitions>
到目前为止,还没有一种SOAP的实现支持重载。这对基于JAVA的客户端十分重要,因为JAVA服务器使用的接口用到JAVA的重载特性。而对基于COM的客户端,就不那么重要,因为COM是不支持重载的。
- Web Service描述语言 WSDL 详解(5)
- Web Service描述语言 WSDL 详解
- Web Service描述语言 WSDL 详解(1)
- Web Service描述语言 WSDL 详解(3)
- Web Service描述语言 WSDL 详解(6)
- Web Service描述语言 WSDL 详解(2)
- Web Service描述语言 WSDL 详解(4)
- Web Service描述语言 WSDL 详解 (一)
- Web Service描述语言 WSDL 详解 (二)
- Web Service描述语言 WSDL 详解 (三)
- Web Service描述语言 WSDL 详解 (1)
- Web Service描述语言 WSDL 详解 (2)
- Web Service描述语言 WSDL 详解
- Web Service描述语言 WSDL 详解
- Web Service描述语言 WSDL 详解
- Web Service描述语言 WSDL 详解
- web service wsdl详解
- web service wsdl详解
- 【转】爱国青年们,不要被人蒙蔽了你明亮的眼睛。。。
- 用XML/XSLT将行数据转换为列数据
- Web Service描述语言 WSDL 详解(1)
- 深入探究JFreeChart(1)
- Web Service描述语言 WSDL 详解(3)
- Web Service描述语言 WSDL 详解(5)
- MP4视频转换通破解 或 MP4/RM转换专家破解
- Web Service描述语言 WSDL 详解(6)
- 进程间通信IPC
- 如何计算今天是今年中的第几个星期.
- Linux系统维护常用工具sysstat
- 跨平台的客场交锋:.NET vs. JAVA on Linux
- 理解UDDI(4):元数据体系tModel——附录
- FTP开源软件FileZilla的学习