客户端:
string contractData =
"<Contract >
<Title>西游记版权合同</Title>
<Copyrights>
<Copyright>
<WorksName>
西游记
</WorksName>
<Copyright>
</Copyrights>
</Contract>";
服务端契约类
[DataContract(Namespace = "http://tianka.com")]
public class Contract
{
[DataMember]
public stringTitle{ get;set;}
private List<Copyright> m_copyrights = new List<Copyright>();
[DataMember]
public List<Copyright> Copyrights
{
get
{
return this.m_copyrights;
}
set
{
this.m_copyrights = value;
}
}
}
[DataContract]
public class Copyright
{
[DataMember]
public string WorksName { get; set; }
}
把contractData通过rest方式提交到服务端CreateContract(Contract c)方法后c.Copyrights总是为null,请高手们帮解答下
将 List<Copyright> 改为 Copyright[] 试试
看下WCF服务代码
public string CreateUser(Contract u)
{
if(u.Copyrights == null) return "fail";
return "ok";
}
这是服务端方rest方法
}
@lllhhu: 你反序列化xml的代码呢?