WCF service method parameter with null properties
I have a WCF service method that takes a complex parameter, which in turn has complex properties. The problem is that this parameter once it arrive开发者_开发知识库s at the server contains null for some of the properties.
I have checked using WCF tracing and Fiddler and the data is definitely going over the wire. Seems to be when the XML is deserialized into .net objects something goes wrong and some properties get set to null.
I've tried rebuilding the proxy in case some mismatch there.
EDIT: OK all fixed now. The data objects were POCO's generated from the EF T4 template and which have a separate field for the foreign key id's. I was forgetting to set this on the client, as soon as I did I started to get the complex properties returned on the server. Not exactly sure why though.
Have you used DataMember on these properties? and if the type is class, you should use DataContract on these types too.
Actually, when you use WCF tracing, you can see the xml.
精彩评论