Is it possible for a WCF Service method to return different types?
I already tried with Object but since it’s not a DataContract type it doesn’t work properly.
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use
known types. Those could also be defined in the config file using the<system.runtime.serialization>section (see Additional Ways to Add Known Types in the article).This being said you probably want to define a base data contract type that all other possible data contracts will derive from and have your operation return this base data contract instead of using object.