开发者

WCF service method parameter with null properties

开发者 https://www.devze.com 2023-03-27 11:44 出处:网络
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 forsom

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消