Saturday 15 January 2011

.net - How do I use KnownType to enable polymorphic return values in a WCF service contract? -


I am converting a remote interface to WCF, though I have a method to return the "object" Has been declared and

(I am using a common contract assembly that contains all types, instead of generating all types are a client proxy if it makes a difference.)

OK, know the type of etip An example of using uT is to note that it allows multiple attributes in the same class, so you can identify more than one polymorphic hair type.

It is quite limited functionality because it allows you to specify known types at design times, so it does not really fit into the expandable and maintenance mindset, which normally makes us use polymorphism in the first place. Does.

Air Force, this limit is mainly due to barriers to WSDL / XSD, for which WCF contracts are often translated. We should always remember that only messages travel in the wire - objects not the other one at the other end. The NET application can not be at all, so for the sake of difference, it is our acceptance of obstacles.

I usually find that a more stable resize interface of service is often a better solution. You can also look in the form of an object, which will translate into XS: Anyone, but obviously you will lose the type of security in the way.

WCF has an advanced option that allows you to share the type between the server and the client, so it can also be a solution for you. However, if you do this, you lose interoperability and many other goodness, so keep this in mind before choosing this option carefully.


No comments:

Post a Comment