Should WCF services return old old objects or the actual class you are working with?

I use a WCF service from another company and return an object of type object. Is there a reason not to return the actual class and return an object that needs to be entered in the correct form?

For example, if a web service returns an object of type OrderStatus, why do you instead return a plain old one object?

Correct me if I am wrong, but this will require that I get the class definition OrderStatusmanually (via email or the like) and put it in my solution. In addition, I will have to explicitly pass the object to the object OrderStatus. Not to mention the fact that the company can change the service to return an object of a different type, and my code will stop working.

If the return value of the service was an object of type OrderStatus, will the class be automatically created for me correctly?

+3
source share
1 answer

No, definitely do not return the "object"! WCF should use DataContracts and define the complete query implementations and possibly the response objects for each call.

Check out these two great Datacontract basics articles:

I have no idea why the developers of these services chose the "object" as the return type - it does not make much sense to me!

Mark

+5
source

Source: https://habr.com/ru/post/1713780/


All Articles