2010-02-02 50 views
3

我正在嘗試創建一個XML架構以與Web服務軟件工廠配合使用。這是一個相當簡單的模式,只是一組人對象。 (簡化)架構文件看起來像:XML架構不適用於Web服務軟件工廠

<?xml version="1.0" encoding="utf-8" ?> 
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" 
    elementFormDefault="qualified" 
    xmlns="http://tempuri.org/XMLSchema.xsd" 
    xmlns:mstns="http://tempuri.org/XMLSchema.xsd" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"> 

    <xs:element name="Persons" type="PersonsType" /> 

    <xs:complexType name="PersonsType"> 
     <xs:sequence> 
      <xs:element name="Person" type="PersonType" minOccurs="0" 
       maxOccurs="unbounded" /> 
     </xs:sequence> 
    </xs:complexType> 

    <xs:complexType name="PersonType"> 
     <xs:all> 
      <xs:element name="PersonName" type="xs:string" /> 
      <xs:element name="PersonAge" type="xs:integer" /> 
     </xs:all> 
    </xs:complexType> 

</xs:schema> 

這是一個父元素人元素的簡單集合稱爲人。

當我嘗試驗證我的.serviceContract文件時,出現錯誤'文件名'Persons.xsd'與DataContactSerializer'不兼容'。

有沒有人知道如何解決這個模式,以便它可以與Web服務軟件工廠一起工作?對於獎勵點,我不得不擔心的下一個結構將是遞歸的公司列表。任何關於如何製作與WSSF一起工作的遞歸模式的建議也將受到讚賞。

回答

1

您是否已經嘗試避免命名類型?

<?xml version="1.0" encoding="utf-8" ?> 
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" 
    elementFormDefault="qualified" 
    xmlns="http://tempuri.org/XMLSchema.xsd" 
    xmlns:mstns="http://tempuri.org/XMLSchema.xsd" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"> 

    <xs:element name="Persons"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element name="Person" minOccurs="0" maxOccurs="unbounded"> 
        <xs:complexType> 
         <xs:all> 
          <xs:element name="PersonName" type="xs:string" /> 
          <xs:element name="PersonAge" type="xs:integer" /> 
         </xs:all> 
        </xs:complexType> 
       </xs:element> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 

你也可以嘗試改變< XS:都在你的<人> >到<序列>。

+0

@fiburt:謝謝你的幫助,但是我試過這個,並且在命名空間'http://tempuri.org/XMLSchema.xsd'中得到了「Type'Person'不能被導入,根序列上的'minOccurs'必須是1 。要麼改變模式,以便這些類型可以映射到數據合約類型或使用ImportXmlType或使用不同的序列化程序。「 – 2010-02-04 20:46:32