I am consuming a WCF service from another company, and it is returning an object of type object. Is there a reason not to return the actual class, and return an object that must be cast into the correct form?
For example, if the web service returns an object of type OrderStatus, why would you instead return a plain old object?
Correct me if I'm wrong, but this will require me to get the definition of the OrderStatus class manually (via email or whatever), and put it in my solution. Plus, I will have to explicitly cast the object to an OrderStatus object. Not to mention that the company could change the service to return an object of another type, and my code will stop working.
If the return value of the service was an object of type OrderStatus, the class would be automatically generated for me right?
No, definitely not return "object" ! WCF should make use of DataContracts and define full implementations of the request and possibly response objects for each call.
See these two excellent articles on Datacontract basics:
I have no idea why the developers of those services picked "object" as the return type - doesn't make a whole lot of sense to me!
Marc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With