问题
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