I have an array of enumerations on a WCF request that comes through as null
, no matter what I have tried.
The service works apart from the issue with enumerations.
Does anyone have any ideas why this might be?
Enumeration code:
[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; }
//...
}
Try to add [KnownType(typeof(Recommendation[]))]
attribute to your MyRequest class
精彩评论