Is creating separate XSD type for data item key good Web Service design, when data item can be identified by multiple attributes?

荒凉一梦 提交于 2020-01-06 02:38:27

问题


I have specified like this because I want different consumers to be able to identify data differently. External consumers don't know about id and internal do.

<!-- all are minoccurs=0 because only data present will be updated -->
<xs:complexType name="tSomeData">
  <xs:sequence>
    <xs:element name="id" type="xs:int" minOccurs="0"/>
    <xs:element name="name" type="xs:string" minOccurs="0"/>
    <xs:element name="externalname" type="xs:string" minOccurs="0"/>
    <xs:element name="manufacturer" type="xs:string" minOccurs="0"/>
    <xs:element name="manufacturertype" type="xs:string" minOccurs="0"/>
    <!-- more values -->
  </xs:sequence>
</xs:complexType>

<xs:complexType name="tSomeKey">
  <xs:choice>
    <xs:element name="id" type="xs:int" />
    <xs:element name="name" type="xs:string" />
    <xs:element name="externalname" type="xs:string" />
  </xs:choice>
</xs:complexType>

<xs:element name="UpdateSome">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="somekey" type="tSomeKey" />
      <xs:element name="somedata" type="tSomeData" />
    </xs:sequence>
  </xs:complexType>
</xs:element>


<xs:element name="GetSome">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="key" type="tSomeKey" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

I think more basic way is to have only 1 element for update and the key is found out from the elements. My approach

Pros: States explicitly the criteria for identification

Cons: Added complexity and verbosity.

So what you think of this approach of separating key and data?

来源:https://stackoverflow.com/questions/29162837/is-creating-separate-xsd-type-for-data-item-key-good-web-service-design-when-da

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!