我有一个关于WCF请求的枚举数组,无论我尝试过什么,它都以null
形式出现。
该服务与枚举问题不同。
有没有人知道为什么会这样?
枚举代码:
[DataContract(Namespace = "http://services.myproject.com/requests/MyProject")]
public enum Recommendation
{
[EnumMember]
One = 1,
[EnumMember]
Two = 2,
}
SOAP XML:
... xmlns:lat="http://services.myproject.com/requests/MyProject" ...
...
<lat:Recommendations>
<Recommendation>One</Recommendation>
<Recommendation>Two</Recommendation>
</lat:Recommendations>
...
C#:
[DataContract(Namespace = "http://services.myproject.com/requests/MyProject")]
public class MyRequest : Request ...
{
//...
[DataMember]
public Recommendation[] Recommendations { get; set; }
//...
}
答案 0 :(得分:3)
尝试将[KnownType(typeof(Recommendation[]))]
属性添加到MyRequest类