2012-02-16 22 views
0

以下はサービスのスキーマです。WCFスキーマの問題

<xs:element name="StartDate" type="tns:DateType"> 
    <xs:annotation> 
    <xs:documentation>The start date of the planning item in question</xs:documentation> 
    </xs:annotation> 
</xs:element> 
<xs:complexType name="DateType"> 
    <xs:annotation> 
    <xs:documentation> 
     0 - Hard Date (Use the date defined by the year, month and day attributes 
     2 - Retirement 
     3 - Death 
     4 - Disability 
     5 - Long Term Care 
    </xs:documentation> 
    </xs:annotation> 
    <xs:sequence> 
    <xs:element name="Date"> 
     <xs:complexType> 
     <xs:attribute name="date_type" use="optional" default="0"> 
      <xs:simpleType> 
      <xs:restriction base="xs:int"> 
       <xs:enumeration value="0"> 
       <xs:annotation> 
        <xs:documentation>Hard Date (Use the date defined by the year, month and day attributes</xs:documentation> 
       </xs:annotation> 
       </xs:enumeration> 
       <xs:enumeration value="2"> 
       <xs:annotation> 
        <xs:documentation>Retirement</xs:documentation> 
       </xs:annotation> 
       </xs:enumeration> 
       <xs:enumeration value="3"> 
       <xs:annotation> 
        <xs:documentation>Death</xs:documentation> 
       </xs:annotation> 
       </xs:enumeration> 
       <xs:enumeration value="4"> 
       <xs:annotation> 
        <xs:documentation>Disability</xs:documentation> 
       </xs:annotation> 
       </xs:enumeration> 
       <xs:enumeration value="5"> 
       <xs:annotation> 
        <xs:documentation>Long Term Care</xs:documentation> 
       </xs:annotation> 
       </xs:enumeration> 
      </xs:restriction> 
      </xs:simpleType> 
     </xs:attribute> 
     </xs:complexType> 
    </xs:element> 
    </xs:sequence> 
</xs:complexType> 

これは私たちがDATE_TYPEで0値を送信するために必要な要件を持っているプロキシクラス

公共部分クラスのDateTypeDate {

private int date_typeField; 


    public DateTypeDate() 
    { 
     this.date_typeField = 0; 
    } 

    /// <remarks/> 
    [System.Xml.Serialization.XmlAttributeAttribute()] 
    [System.ComponentModel.DefaultValueAttribute(0)] 
    public int date_type 
    { 
     get 
     { 
      return this.date_typeField; 
     } 
     set 
     { 
      this.date_typeField = value; 
     } 
    } 


} 

です。

1-私はデフォルトで "0"の値を割り当てるべきであると仮定して以下を試しました。

StartDate = new DateType(); 
    DateTypeDate date = new DateTypeDate(); 

2-、私は明示的に両方の場合において0

StartDate = new DateType(); 
    DateTypeDate date = new DateTypeDate(); 
    date.date_type = 0; 
    StartDate.Date = date; 

に「DATE_TYPE」値を割り当てる「DATE_TYPE」ノードは、サービスに介して送信される実際の要求XMLで表示されません。これは生成されるリクエストxmlです。

<StartDate> 
    <Date></Date> 
    </StartDate> 

But if i assign a different value than 0 then i can see the date_type node. for example 

    <StartDate> 
    <Date date_type="2"></Date> 
    </StartDate> 


Would you able to help what could be the reason that node doesn't appear in request xml id i assign it to "0" also is there any way the node can appear without making chnages in schema. Thanks in advance 

答えて

0

私はXML Schemaの専門家ではないんだけど、問題は、スキーマ内の次の行でほぼ確実である私には思える:属性はつまり、オプションである場合

<xs:attribute name="date_type" use="optional" default="0"> 

クライアントはそれを送信する必要はありません。代わりにそれを必要とするようにしてください。