欢迎光临
我们一直在努力

soap规范(3)-JSP教程,资料/其它

建站超值云服务器,限时71元/月

以下是一个同时具有简单和复杂成员类型的例子。它显示两层引用。注意"author"accssor元素的"href"属性是对相应具有"id"属性的值的引用。"address"与之类似。

<e:book>
   <title>my life and work</title>
   <author href="#person-1"/>
</e:book>
<e:person id="person-1">
   <name>henry ford</name>
   <address href="#address-2"/>
</e:person>
<e:address id="address-2">
   <email>mailto:henryford@hotmail.com</email>
   <web>http://www.henryford.com</web>
</e:address>

当"person"的值和"address"的值是multi-reference时,上面的形式是正确的。如果它们是single-reference,就必须用嵌入的形式,如下所示:

<e:book>
   <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>
如果添加一个限制,任意两个人都不会有相同的地址,并且地址可以是街道或email地址,一本书可以有两个作者,编码如下:

<e:book>
   <title>my life and work</title>
   <firstauthor href="#person-1"/>
   <secondauthor href="#person-2"/>
</e:book>
<e:person id="person-1">
   <name>henry ford</name>
   <address xsi:type="m:electronic-address">
       <email>mailto:henryford@hotmail.com</email>
       <web>http://www.henryford.com</web>
   </address>
</e:person>
<e:person id="person-2">
   <name>samuel crowther</name>
   <address xsi:type="n:street-address">
       <street>martin luther king rd</street>
       <city>raleigh</city>
       <state>north carolina</state>
   </address>
</e:person>

序列化可以包含对不在同一个资源的值的引用:

<e:book>
   <title>paradise lost</title>
   <firstauthor href="http://www.dartmouth.edu/~milton/"/>
</e:book>

以下是描述上面结构的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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » soap规范(3)-JSP教程,资料/其它
分享到: 更多 (0)