0

这是我的服务的 xml 输出。

<LifeAreas>
    <Overall i:nil="true"/>
    <Career>
        <Good>
            <NamePlanet/>
            <NamePlanet/>
        </Good>
        <Neutral>
            <NamePlanet/>
            <NamePlanet/>
            <NamePlanet/>
        </Neutral>
        <Bad>
             <NamePlanet/>
             <NamePlanet/>
             <NamePlanet/>
             <NamePlanet/>
        </Bad>
   </Career>
   <Finance i:nil="true"/>
   <Relationship i:nil="true"/>
   <Health i:nil="true"/>

使用的 DataContract 如下:

[DataContract(Name = "Areas", Namespace = "")] 
public sealed class Areas
{ 
    [DataMember(Name = "Overall", Order = 0)]
    public PlanetDiginity Overall { get; set; }

    [DataMember(Name = "Career", Order = 1)]
    public PlanetDiginity Career { get; set; }

    [DataMember(Name = "Finance", Order = 2)]
    public PlanetDiginity Finance { get; set; }

    [DataMember(Name = "Relationship", Order = 3)]
    public PlanetDiginity Relationship { get; set; }

    [DataMember(Name = "Health", Order = 4)]
    public PlanetDiginity Health { get; set; }
}

[DataContract(Name = "NamePlanet", Namespace = "")]  
public sealed class NamePlanet
{
    public string PlanetName { get; set; }
}

[DataContract(Name = "PlanetDiginity", Namespace = "")] 
public sealed class PlanetDiginity
{
    ///<summary>
    /// Gets and Sets the Planet Diginity
    /// </summary>
    [DataMember(Name = "Good", Order = 0)]
    public List<NamePlanet> Good { get; set; }

    [DataMember(Name = "Neutral", Order = 1)]
    public List<NamePlanet> Neutral { get; set; }

    [DataMember(Name = "Bad", Order = 2)]
    public List<NamePlanet> Bad { get; set; }
}

[DataContract(Name = "GoodBadPlanetList", Namespace = "")]
public sealed class GoodBadPlanetList
{
    [DataMember(Name = "GoodBadPlanetReport", Order = 2)]
    public List<GoodBadPlanetReport> GoodBadPlanetReport { get; set; }

    [DataMember(Name = "AstroDetails", Order = 0)]
    public AstroInfo AstroDetails { get; set; }

    [DataMember(Name = "LifeAreas", Order = 1)]
    public Areas LifeAreas { get; set; }
}

从 web 服务,所需的数据来自节点,但在 xml 中它没有显示。只有它在列表中多次显示属性名称。

4

1 回答 1

0

NamePlanet 类的 PlanetName 属性似乎缺少 DataMember 属性

于 2012-09-03T06:10:52.083 回答