Is it possible to return objects from a WebService?
web-services
Solution
As mentioned, you can do this in .net via serialization. By default all native types are serializable so this happens automagically for you.
However if you have complex types, you need to mark the object with the [Serializable] attribute. The same goes with complex types as properties.
So for example you need to have:
[Serializable]
public class MyClass
{
public string MyString {get; set;}
[Serializable]
public MyOtherClass MyOtherClassProperty {get; set;}
}
Problem
Instead of returning a common string, is there a way to return classic objects? If not: what are the best practices? Do you transpose your object to xml and rebuild the object on the other side? What are the other possibilities?