简体   繁体   中英

WCF DataContract

I have one datacontract as base object and i have two derived datacontract object.

In Operation contract i return only base object.

SO since base object is represnted in service and opreational contract the derived class are not visible in client side (or) not publish in web service.?

how can i create the derived object in client side and return via operational contract through its base object reference.

(or)

How can I expose the datacontract object in service but not in operation contract to webservice that i can consume from web reference.

thks dinesh

使用KnownType属性。

I'm not sure that you can. The issue as I see it that you are moving the base class across the wire since that is what is defined in the operational contract. That means that any extensions you make with derived classes will not get moved across the wire since only the base class will be serialized.

edit: After reading davogones post, he definitely has a point. I guess it really hinges whether there is an expectation of additional fields being involved. That was my thinking above anyhow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM