📄 soap4.htm
字号:
<P><BR>复合值的成员被编码为存取标识元素。存取标识由他们的名字来相区别(例如在struct里面),而元素名就是存取标识名。存取标识名是局部的,作用域是包含他们的类型中,具备一个未修饰的元素名,而其他则有完全修饰名。</P>
<P></P>
<P>下面是一个“Book”结构的例子:</P>
<P></P>
<P></P>
<P>Example 18</P>
<P><BR><e:Book xmlns:e="http://example.org/2001/06/books" >
<author>Henry Ford</author> <preface>Prefactory
text</preface> <intro>This is a
book.</intro></e:Book></P>
<P><BR>Book structure</P>
<P><BR>下面则是一个描述该结构的模式片段:</P>
<P></P>
<P></P>
<P>Example 19</P>
<P><BR><xs:element name="Book"
xmlns:xs='http://www.w3.org/2001/XMLSchema' >
<xs:complexType> <xs:sequence> <xs:element
name="author" type="xs:string" /> <xs:element name="preface"
type="xs:string" /> <xs:element name="intro" type="xs:string"
/> </xs:sequence>
</xs:complexType></xs:element></P>
<P><BR>Schema for Example 18</P>
<P><BR>下面是一个即包含简单类型成员也包含复合类型成员的类型的例子。它显示了两层的引用。注意“Author”存取标识元素的“href”属性一个对匹配“id”值对应的值的引用。“Address”中的情况也是类似的。</P>
<P></P>
<P></P>
<P>Example 20</P>
<P><BR><e:Book xmlns:e="http://example.org/2001/06/books" >
<title>My Life and Work</title> <author
href="#Person-1"/></e:Book><e:Person
xmlns:e="http://example.org/2001/06/books" id="Person-1" >
<name>Henry Ford</name> <address
href="#Address-2"/></e:Person><e:Address
xmlns:e="http://example.org/2001/06/books" id="Address-2" >
<email>mailto:henryford@hotmail.com</email>
<web>http://www.henryford.com</web></e:Address></P>
<P><BR>Book with muli-reference addresses</P>
<P><BR>当“Person”和“Address”的值是需要多引用的时候,上述描述是合适的。如果使用单引用来描述,则应该是嵌入的,如下:</P>
<P></P>
<P></P>
<P>Example 21</P>
<P><BR><e:Book xmlns:e="http://example.org/2001/06/books" >
<title>My Life and Work</title> <author>
<name>Henry Ford</name> <address>
<email>mailto:henryford@hotmail.com</email>
<web>http://www.henryford.com</web> </address>
</author></e:Book></P>
<P><BR>Book with single-reference addresses</P>
<P><BR>如果这里存在着一个限制:在一个给出的实例中不允许有两个人有同样的地址,地址可以是一个街道地址(Street-address),也可以是一个电子地址(Electronic-address)。一本有两个作者的书可以编码为:</P>
<P></P>
<P></P>
<P>Example 22</P>
<P><BR><e:Book xmlns:e="http://example.org/2001/06/books" >
<title>My Life and Work</title> <firstauthor
href="#Person-1"/> <secondauthor
href="#Person-2"/></e:Book><e:Person
xmlns:e="http://example.org/2001/06/books"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Person-1"
> <name>Henry Ford</name> <address
xsi:type="e:ElectronicAddressType">
<email>mailto:henryford@hotmail.com</email>
<web>http://www.henryford.com</web>
</address></e:Person><e:Person
xmlns:e="http://example.org/2001/06/books"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="Person-2"> <name>Samuel Crowther</name>
<address xsi:type="e:StreetAddressType"> <street>Martin
Luther King Rd</street> <city>Raleigh</city>
<state>North Carolina</state>
</address></e:Person></P>
<P><BR>Book with two authors having different addresses</P>
<P><BR>编序也可以包含一些不在同一资源中的值的引用:</P>
<P></P>
<P></P>
<P>Example 23</P>
<P><BR><e:Book xmlns:e="http://example.org/2001/06/books" >
<title>Paradise Lost</title> <firstAuthor
href="http://www.dartmouth.edu/~milton/" /></e:Book></P>
<P><BR>Book with external references</P>
<P><BR>同时下面是一个对上面结构的模式描述片段:</P>
<P></P>
<P></P>
<P>Example 24</P>
<P><BR><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.org/2001/06/books"
targetNamespace="http://example.org/2001/06/books" >
<xs:element name="Book" type="tns:BookType" />
<xs:complexType name="BookType" > <xs:annotation>
<xs:documentation> <info> Either the following group
must occur or else the href attribute must appear, but not both.
</info> </xs:documentation> </xs:annotation>
<xs:sequence minOccurs="0" maxOccurs="1" > <xs:element
name="title" type="xs:string" /> <xs:element
name="firstAuthor" type="tns:PersonType" /> <xs:element
name="secondAuthor" type="tns:PersonType" /> </xs:sequence>
<xs:attribute name="href" type="xs:anyURI" /> <xs:attribute
name="id" type="xs:ID" /> <xs:anyAttribute namespace="##other"
/> </xs:complexType> <xs:element name="Person"
type="tns:PersonType" /> <xs:complexType name="PersonType"
> <xs:annotation> <xs:documentation> <info>
Either the following group must occur or else the href attribute
must appear, but not both. </info> </xs:documentation>
</xs:annotation> <xs:sequence minOccurs="0" maxOccurs="1"
> <xs:element name="name" type="xs:string" />
<xs:element name="address" type="tns:AddressType" />
</xs:sequence> <xs:attribute name="href" type="xs:anyURI"
/> <xs:attribute name="id" type="xs:ID" />
<xs:anyAttribute namespace="##other" />
</xs:complexType> <xs:element name="Address"
base="tns:AddressType" /> <xs:complexType name="AddressType"
abstract="true" > <xs:annotation> <xs:documentation>
<info> Either one of the following sequences must occur or
else the href attribute must appear, but not both. </info>
</xs:documentation> </xs:annotation> <xs:choice>
<xs:sequence minOccurs="0" maxOccurs="1" > <xs:element
name="email" type="xs:string" /> <xs:element name="web"
type="xs:anyURI" /> </xs:sequence> <xs:sequence
minOccurs='0' maxOccurs='1' > <xs:element name="street"
type="xs:string" /> <xs:element name="city" type="xs:string"
/> <xs:element name="state" type="xs:string"/>
</xs:sequence> </xs:choice> <xs:attribute name="href"
type="xs:anyURI"/> <xs:attribute name="id" type="xs:ID"/>
<xs:anyAttribute namespace="##other"/> </xs:complexType>
<xs:complexType name="StreetAddressType">
<xs:annotation> <xs:documentation> <info> Either
the second sequence in the following group must occur or else the
href attribute must appear, but not both. </info>
</xs:documentation> </xs:annotation>
<xs:complexContent> <xs:restriction base="tns:AddressType"
> <xs:sequence> <xs:sequence minOccurs="0" maxOccurs="0"
> <xs:element name="email" type="xs:string" />
<xs:element name="web" type="xs:anyURI" />
</xs:sequence> <xs:sequence minOccurs="0" maxOccurs="1">
<xs:element name="street" type="xs:string" /> <xs:element
name="city" type="xs:string" /> <xs:element name="state"
type="xs:string"/> </xs:sequence> </xs:sequence>
<xs:attribute name="href" type="xs:anyURI"/> <xs:attribute
name="id" type="xs:ID"/> <xs:anyAttribute
namespace="##other"/> </xs:restriction>
</xs:complexContent> </xs:complexType>
<xs:complexType name="ElectronicAddressType">
<xs:annotation> <xs:documentation> <info> Either
the first sequence in the following group must occur or else the
href attribute must appear, but not both. </info>
</xs:documentation> </xs:annotation>
<xs:complexContent> <xs:restriction base="tns:AddressType"
> <xs:sequence> <xs:sequence minOccurs="0"
maxOccurs="1"> <xs:element name="email" type="xs:string" />
<xs:element name="web" type="xs:anyURI" />
</xs:sequence> <xs:sequence minOccurs="0" maxOccurs="0">
<xs:element name="street" type="xs:string" /> <xs:element
name="city" type="xs:string" /> <xs:element name="state"
type="xs:string"/> </xs:sequence> </xs:sequence>
<xs:attribute name="href" type="xs:anyURI"/> <xs:attribute
name="id" type="xs:ID"/> <xs:anyAttribute
namespace="##other"/> </xs:restriction>
</xs:complexContent>
</xs:complexType></xs:schema></P>
<P><BR>Schema for example 22</P>
<P><BR>5.4.2 数组</P>
<P><BR>SOAP数组被定义为类型为“enc:Array”或类型源于“enc:Array”(可参阅 rule
8)。这种类型源于"enc:Array"的类型必须遵从"enc:Array"的限制,同时它可用于表示以下情况的类型定义,譬如整型数的数组或是一些用户自定义的枚举类型的数组等。数组被表示为对包含其的元素的名无特殊约束的元素值(就象值一般不会约束包含元素的名)。组成数组的元素可以是任意类型,包括嵌套的数组。</P>
<P></P>
<P>数组值的表示是一个该数组组成元素的一个有序序列。作为一个数组的值,元素名对于区分存取标识并非重要。元素可以有任意的名。实际上,这些元素的命名将按照模式中声明的建议,或由他们的类型所决定。就象在复合类型中通常情况下,如果数组中条目的值是单引用值,则该条目将包含它的值。否则,条目通过“href”属性引用它的值。</P>
<P></P>
<P>下面是一个模式的片段以及一个包含integer成员的数组:</P>
<P></P>
<P></P>
<P>Example 25</P>
<P><BR><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:enc="http://www.w3.org/2001/06/soap-encoding" >
<xs:import namespace="http://www.w3.org/2001/06/soap-encoding"
/> <xs:element name="myFavoriteNumbers" type="enc:Array"
/></xs:schema></P>
<P><BR>Schema declaring an array of integers</P>
<P><BR> </P>
<P></P>
<P></P>
<P>Example 26</P>
<P><BR><myFavoriteNumbers
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:enc="http://www.w3.org/2001/06/soap-encoding"
enc:arrayType="xs:int[2]" > <number>3</number>
<number>4</number></myFavoriteNumbers></P>
<P><BR>Array conforming to the schema in Example 25</P>
<P><BR>在这个例子中,“myFavoriteNumber”数组包含了几个成员,每个成员的值的类型都是xs:int。而类型是由enc:arrayType属性决定的。注意enc:Array的类型允许不严格的未修饰的元素名。这些名只传输了非类型的信息,因此在具体使用的时候,要么有一个xsi:type属性,要么包含它的元素要包含一个enc:arrayType属性。自然地,源于enc:Array的类型可以声明带类型信息的局部元素。</P>
<P></P>
<P>就象先前指出的,enc模式包含了一些元素名的声明,而这些名是对应于“XML Schema Part 2:
Datatypes”规范[11]中的每个简单类型的。这也包含一个“Array”的声明。使用这些定义,我们也许可以将显现先前的描述改写为:</P>
<P></P>
<P></P>
<P>Example 27</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -