<p>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? </p>

[{'answer_id': 11883, 'author': 'Jon Limjap', 'author_id': 372, 'author_profile': 'https://Stackoverflow.com/users/372', 'pm_score': 2, 'selected': False, 'text': '<p>Yes: in .NET they call this serialization, where objects are serialized into XML and then reconstructed by the consuming service back into its original object type or a surrogate with the same data structure.</p>\n'}, {'answer_id': 11884, 'author': 'Kev', 'author_id': 419, 'author_profile': 'https://Stackoverflow.com/users/419', 'pm_score': 3, 'selected': False, 'text': '<p>If the object can be serialised to XML and can be described in WSDL then yes it is possible to return objects from a webservice.</p>\n'}, {'answer_id': 11899, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 4, 'selected': True, 'text': '<p>As mentioned, you can do this in .net via serialization. By default all native types are serializable so this happens automagically for you.</p>\n\n<p>However if you have complex types, you need to mark the object with the [Serializable] attribute. The same goes with complex types as properties.</p>\n\n<p>So for example you need to have:</p>\n\n<pre><code>[Serializable]\npublic class MyClass\n{\n    public string MyString {get; set;}\n\n    [Serializable]\n    public MyOtherClass MyOtherClassProperty {get; set;}\n}\n</code></pre>\n'}, {'answer_id': 11900, 'author': 'Seibar', 'author_id': 357, 'author_profile': 'https://Stackoverflow.com/users/357', 'pm_score': 1, 'selected': False, 'text': '<p>.NET automatically does this with objects that are serializable. I\'m pretty sure Java works the same way.</p>\n\n<p>Here is an article that talks about object serialization in .NET:\n<a href="http://www.codeguru.com/Csharp/Csharp/cs_syntax/serialization/article.php/c7201/" rel="nofollow noreferrer">http://www.codeguru.com/Csharp/Csharp/cs_syntax/serialization/article.php/c7201</a></p>\n'}, {'answer_id': 11902, 'author': 'Matthew Schinckel', 'author_id': 188, 'author_profile': 'https://Stackoverflow.com/users/188', 'pm_score': 2, 'selected': False, 'text': '<p>Where possible, I transpose the objects into XML - this means that the Web Service is more portable - I can then access the service in whatever language, I just need to create the parser/object transposer in that language.</p>\n\n<p>Because we have WSDL files describing the service, this is almost automated in some systems.</p>\n\n<p>(For example, we have a server written in pure python which is replacing a server written in C, a client written in C++/gSOAP, and a client written in Cocoa/Objective-C.  We use soapUI as a testing framework, which is written in Java).</p>\n'}, {'answer_id': 11923, 'author': 'Brian', 'author_id': 725, 'author_profile': 'https://Stackoverflow.com/users/725', 'pm_score': 2, 'selected': False, 'text': "<p>It is possible to return objects from a web service using XML.  But Web Services are supposed to be platform and operating system agnostic.  Serializing an object simply allows you to store and retrieve an object from a byte stream, such as a file.  For instance, you can serialize a Java object, convert that binary stream (perhaps via a Base 64 encoding into a CDATA field) and transfer that to service's client.</p>\n\n<p>But the client would only be able to restore that object if it were Java-based.  Moreover, a deep copy is required to serialize an object and have it restored exactly.  Deep copies can be expensive.</p>\n\n<p>Your best route is to create an XML schema that represents the document and create an instance of that schema with the object specifics.</p>\n"}, {'answer_id': 11929, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 1, 'selected': False, 'text': "<p>@Brian: I don't know how things work in Java, but in .net objects get serialized down to XML, not base64 strings. The webservice publishes a wsdl file that contains the method and object definitions required for your webservice.</p>\n\n<p>I would hope that nobody creates webservices that simply create a base64 string</p>\n"}, {'answer_id': 14102, 'author': 'Daniel Auger', 'author_id': 1644, 'author_profile': 'https://Stackoverflow.com/users/1644', 'pm_score': 0, 'selected': False, 'text': "<p>As others have said, it is possible. However, if both the service and client use an object that has the exact same domain behavior on both sides, you probably didn't need a service in the first place. </p>\n"}, {'answer_id': 15503, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n  <p>As others have said, it is possible.\n  However, if both the service and\n  client use an object that has the\n  exact same domain behavior on both\n  sides, you probably didn't need a\n  service in the first place.</p>\n</blockquote>\n\n<p>I have to disagree with this as it's a somewhat narrow comment. Using a webservice that can serialize domain objects to XML means that it makes it easy for clients that work with the same domain objects, but it also means that those clients are restricted to using that particular web service you've exposed and it also works in reverse by allowing other clients to have no knowledge of your domain objects but still interact with your service via XML.</p>\n"}, {'answer_id': 20251, 'author': 'Daniel Auger', 'author_id': 1644, 'author_profile': 'https://Stackoverflow.com/users/1644', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <blockquote>\n    <p><strong>Daniel Auger:</strong><br>\n    As others have said, it is possible.\n    However, if both the service and\n    client use an object that has the\n    exact same domain behavior on both\n    sides, you probably didn\'t need a\n    service in the first place.</p>\n  </blockquote>\n  \n  <p><strong>lomax:</strong>\n  I have to disagree with this as it\'s a\n  somewhat narrow comment. Using a\n  webservice that can serialize domain\n  objects to XML means that it makes it\n  easy for clients that work with the\n  same domain objects, but it also means\n  that those clients are restricted to\n  using that particular web service\n  you\'ve exposed and it also works in\n  reverse by allowing other clients to\n  have no knowledge of your domain\n  objects but still interact with your\n  service via XML.</p>\n</blockquote>\n\n<p>@ Lomax: You\'ve described two scenarios. <strong>Scenario 1:</strong> The client is rehydrating the xml message back into the exact same domain object. I consider this to be "returning an object". In my experience this is a bad choice and I\'ll explain this below. <strong>Scenario 2:</strong> The client rehydrates the xml message into something other than the exact same domain object: I am 100% behind this, however I don\'t consider this to be returning a domain object. It\'s really sending a message or DTO.</p>\n\n<p>Now let me explain why true/pure/not DTO object serialization across a web service is <em>usually</em> a bad idea. An assertion: in order to do this in the first place, you either have to be the owner of both the client and the service, or provide the client with a library to use so that they can rehydrate the object back into it\'s true type. The problem: This domain object as a type now exists in and belongs to two semi-related domains. Over time, behaviors may need to be added in one domain that make no sense in the other domain and this leads to pollution and potentially painful problems.  </p>\n\n<p>I usually default to scenario 2. I only use scenario 1 when there is an overwhelming reason to do so.</p>\n\n<p>I apologize for being so terse with my initial reply. I hope this clears things up to a degree as far as what my opinion is. Lomax, it would seem we half agree ;).</p>\n'}, {'answer_id': 20401, 'author': 'Brendan', 'author_id': 199, 'author_profile': 'https://Stackoverflow.com/users/199', 'pm_score': 1, 'selected': False, 'text': '<p>JSON is a pretty standard way to pass objects around the web (as a subset of javascript). Many languages feature a library which will convert JSON code into a native object - see for example <a href="http://undefined.org/python/#simplejson" rel="nofollow noreferrer">simplejson</a> in Python.</p>\n\n<p>For more libraries for JSON use, see the <a href="http://www.json.org/" rel="nofollow noreferrer">JSON webpage</a></p>\n'}]
['https://Stackoverflow.com/questions/11879', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/391/']