分享
 
 
 

SOAP协议规范(二)

王朝other·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

以下是描述上面结构的schema片断:

<element name="book" type="tns:book"/>

<complexType name="Book">

<!-- Either the following group must occur or else the

href attribute must appear, but not both. -->

<sequence minOccurs="0" maxOccurs="1">

<element name="title" type="xsd:string"/>

<element name="firstauthor" type="tns:Person"/>

<element name="secondauthor" type="tns:Person"/>

</sequence>

<attribute name="href" type="uriReference"/>

<attribute name="id" type="ID"/>

<anyAttribute namespace="##other"/>

</complexType>

<element name="Person" base="tns:Person"/>

<complexType name="Person">

<!-- Either the following group must occur or else the

href attribute must appear, but not both. -->

<sequence minOccurs="0" maxOccurs="1">

<element name="name" type="xsd:string"/>

<element name="address" type="tns:Address"/>

</sequence>

<attribute name="href" type="uriReference"/>

<attribute name="id" type="ID"/>

<anyAttribute namespace="##other"/>

</complexType>

<element name="Address" base="tns:Address"/>

<complexType name="Address">

<!-- Either the following group must occur or else the

href attribute must appear, but not both. -->

<sequence minOccurs="0" maxOccurs="1">

<element name="street" type="xsd:string"/>

<element name="city" type="xsd:string"/>

<element name="state" type="xsd:string"/>

</sequence>

<attribute name="href" type="uriReference"/>

<attribute name="id" type="ID"/>

<anyAttribute namespace="##other"/>

</complexType>

5.4.2 数组

SOAP数组定义为具有"SOAP-ENC:Array"类型或一个从"SOAP-ENC:Array"衍生的类型(参见规则8)。数组表示为元素值,对元素的名没有特别的约束(正如元素值并不约束它们所属的元素)。数组可以包含任意类型的元素,包括嵌套数组。可以创建新的类型(受SOAP-ENC:Array

类型限制)来表示数组,如整数数组或某些用户定义的枚举。数组值表示为组成这个数组的项的元素的规则序列。在数组值中,元素名对于区分accesor并不重要。元素可以有任意的名。实际上,元素常常用它们在schema中暗示或确定的数组类型来命名元素。并且一般情况下对于复合值来说,如果数组中数组项的值是single-reference值,则这个数组项包含它的值,否则,该数组项通过"href"属性引用这个值。下面的例子是一个整型数组的schema片断:

<element name="myfavoritenumbers"

type="SOAP-ENC:Array"/>

<myFavoriteNumbers

SOAP-ENC:arrayType="xsd:int[2]">

<number>3</number>

<number>4</number>

</myFavoriteNumbers>

在这个例子中,数组"myfavoritenumbers"包括几个成员,每个成员是一个类型为soap-enc:int的值。注意soap-enc:array允许不受限制的元素名,它们不传达任何类型信息,所以在使用时,或者它们有xsi:type属性,或者它们所属的元素有soap-enc:arraytype属性。自然,由soap-enc:array衍生的类型可以声明局部元素,但这种情况下要包括类型信息。上面已经提到,soap-enc schema包含了元素的声明,元素名与"xml schema part 2: datatypes"规范[11]中的简单类型一致。其中包括了对"array"的声明。于是,我们可以这样写:

<soap-enc:array soap-enc:arraytype="xsd:int[2]">

<SOAP-ENC:int>3</SOAP-ENC:int>

<SOAP-ENC:int>4</SOAP-ENC:int>

</SOAP-ENC:Array>

数组可以包含特定arraytype的任意子类型的实例。即,数组成员可以是arrytype属性值指定的类型的任意子类型,这个类型对于arraytype属性中指定的类型来说是可替换的(根据schema中的替换规则)。例如,一个整型数组可以包含从整型衍生的任意类型(如"int"或任意用户定义的从整型衍生的类型)。同样,一个"address"数组可能包含一个address的受限类型或扩展类型如"internationaladdress"。因为提供的soap-enc:array类型允许任意类型的成员,所以可以包含任意类型的混合除非使用arraytype属性加以特别的限制。在实例中,可以使用xsi:type指定成员元素的类型,或通过schema中成员元素的声明来指定。下面是两个例子。

<soap-enc:array soap-enc:arraytype="soap-enc:ur-type[4]">

<thing xsi:type="xsd:int">12345</thing>

<thing xsi:type="xsd:decimal">6.789</thing>

<thing xsi:type="xsd:string">

Of Mans First Disobedience, and the Fruit

Of that Forbidden Tree, whose mortal tast

Brought Death into the World, and all our woe,

</thing>

<thing xsi:type="xsd:uriReference">http://www.dartmouth.edu/~milton/reading_room/ </thing>

</SOAP-ENC:Array>

<SOAP-ENC:Array SOAP-ENC:arrayType="SOAP-ENC:ur-type[4]">

<SOAP-ENC:int>12345</SOAP-ENC:int>

<SOAP-ENC:decimal>6.789</SOAP-ENC:decimal>

<xsd:string>

Of Mans First Disobedience, and the Fruit

Of that Forbidden Tree, whose mortal tast

Brought Death into the World, and all our woe,

</xsd:string>

<SOAP-ENC:uriReference>http://www.dartmouth.edu/~milton/reading_room/ </SOAP-ENC:uriReference >

</SOAP-ENC:Array>

数组值可以是结构或其它复合值。例如"xyz:order"结构数组:

<soap-enc:array soap-enc:arraytype="xyz:order[2]">

<Order>

<Product>Apple</Product>

<Price>1.56</Price>

</Order>

<Order>

<Product>Peach</Product>

<Price>1.48</Price>

</Order>

</SOAP-ENC:Array>

数组成员值也可以是数组。下例是两个字符串数组组成的数组:

<soap-enc:array soap-enc:arraytype="xsd:string[][2]">

<item href="#array-1"/>

<item href="#array-2"/>

</SOAP-ENC:Array>

<SOAP-ENC:Array id="array-1" SOAP-ENC:arrayType="xsd:string[2]">

<item>r1c1</item>

<item>r1c2</item>

<item>r1c3</item>

</SOAP-ENC:Array>

<SOAP-ENC:Array id="array-2" SOAP-ENC:arrayType="xsd:string[2]">

<item>r2c1</item>

<item>r2c2</item>

</SOAP-ENC:Array>

包含数组的元素无需命名为"soap-enc:array"。它可以有任意的名,只要元素的类型是soap-enc:array或由之衍生的类型。例如,下面是一个schema片断和与之一致的数组实例。

<simpletype name="phonenumber" base="string"/>

<element name="ArrayOfPhoneNumbers">

<complexType base="SOAP-ENC:Array">

<element name="phoneNumber" type="tns:phoneNumber" maxOccurs="unbounded" />

</complexType>

<anyAttribute/>

</element>

<xyz:ArrayOfPhoneNumbers SOAP-ENC:arrayType="xyz:phoneNumber[2]">

<phoneNumber>206-555-1212</phoneNumber>

<phoneNumber>1-888-123-4567</phoneNumber>

</xyz

[1] [2] [3] [4] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有