Is it possible to change WCF service without regenerating & recompiling client proxy?
Let's say I have a WCF service which has a method returning object Person. In one of the clients of this service, I can add service refere开发者_运维问答nce to the service and start using its method.
Now, let's say the Person class is changed on the server, having a new DataMember added. Other clients will make use of this new DataMember, but my client doesn't. Therefore, this client shouldn't even be aware that the service returns s/t "more" than what it needs.
Is there any way that my client can still work with the service without having to update the service reference (which, as I understand, means regenerating the proxy & compiling it)?
This should be fine, as far as the DataContractSerializer
([normally] used by WCF) goes. If I serialize a Person class with 4 properties, save this to a file, remove a couple of properties from Person, recompile and deserialize a Person object from the file, it all works fine. In this case the deserializer is getting more properties than it expects, and they are just ignored.
Note that the above example is just using the DataContractSerializer
, not full WCF. You might run into some problems on the WSDL side of things if you have specified specific ordering; the best way to be sure is to knock up a simple test program.
精彩评论