2012-02-16 5 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

그럼 내가 명시 적으로 "date_type는"실제 요청 XML에 표시되지 않습니다 노드가 서비스를 통해 전송되는 두 경우 모두 0

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

에 "date_type"값을 할당합니다. 생성 된 request 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 스키마 전문가 모르겠지만,이 문제는 스키마에 다음 줄의 거의 확실하다 나에게 보인다 속성이 의미가 선택 사항 인 경우

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

클라이언트는 그것을 보낼 필요가 없습니다. 대신 필요하게 만드십시오.