<p>Hello again ladies and gents!</p>
<p>OK, following on from my other question on <a href="https://stackoverflow.com/questions/6681/aspnet-web-service-results-proxy-classes-and-type-conversion">ASP.NET Web Service Results, Proxy Classes and Type Conversion</a>. I've come to a part in my project where I need to get my thinking cap on.</p>
<p>Basically, we have a large, complex custom object that needs to be returned from a Web Service and consumed in the client application.</p>
<p>Now, based on the previous discussion, we know this is going to then take the form of the proxy class(es) as the return type. To overcome this, we need to basically copy the properties from one to the other.</p>
<p>In this case, that is something that I would really, really, <em>really!</em> like to avoid!</p>
<p>So, it got me thinking, <strong>how else could we do this?</strong></p>
<p>My current thoughts are to enable the object for complete serialization to XML and then return the XML as a string from the Web Service. We then de-serialize at the client. This will mean a fair bit of attribute decorating, but at least the code at both endpoints will be light, namely by just using the .NET XML Serializer.</p>
<h2>What are your thoughts on this?</h2>

[{'answer_id': 17729, 'author': 'mercutio', 'author_id': 1951, 'author_profile': 'https://Stackoverflow.com/users/1951', 'pm_score': 1, 'selected': False, 'text': '<p>I had some great answers on a very similar topic yesterday that might be useful for you:</p>\n\n<p><a href="https://stackoverflow.com/questions/16529/communication-between-javascript-and-the-server">Communication between javascript and the server</a></p>\n'}, {'answer_id': 17745, 'author': 'Cheekysoft', 'author_id': 1820, 'author_profile': 'https://Stackoverflow.com/users/1820', 'pm_score': 4, 'selected': True, 'text': "<p>The .Net XML (de)serialisation is pretty nicely implemented. At first thought, I don't think this is a bad idea at all.</p>\n\n<p>If the two applications import the same C# class(es) definition(s), then this is a relatively nice way of getting copy-constructor behaviour for free. If the class structure changes, then everything will work when both sides get the new class definition, without needing to make any additional changes on the web-service consumption/construction side.</p>\n\n<p>There's a slight overhead in marshalling and demarshalling the XML, but that is probably dwarved by the overhead of the remote web service call. .Net XML serialisation is well understood by most programmers and should produce an easy to maintain solution.</p>\n"}, {'answer_id': 17778, 'author': 'Peter Short', 'author_id': 158302, 'author_profile': 'https://Stackoverflow.com/users/158302', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m loving <code>JSON</code> for this kind of thing. I just finished a POC drop-things type portal for my company using <code>jQuery</code> to contact web services with script service enabled. The messages are lightweight and parsing etc is pretty much handled. The <code>jQuery ajax</code> stuff I read was here (loving it!) : <a href="http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/" rel="nofollow noreferrer">jquery ajax article</a></p>\n'}, {'answer_id': 17856, 'author': 'Peter Meyer', 'author_id': 1875, 'author_profile': 'https://Stackoverflow.com/users/1875', 'pm_score': 1, 'selected': False, 'text': '<p>Rob, in looking at your other question as well as this one, it\'s sounds like the exact situation we have in our environment.  What we\'ve done, however, is move away from ASP.Net web services to WCF web services and in the process solved (for the most part) this problem.  </p>\n\n<p>If there is any chance your web service could be implemented as a WCF web service, this might work for you as well.  I should mention, that at the same time, we\'ve maintained backwards compatibility with some client applications that need the "ASP.Net web service style" of implementation by using the WCF basichttp binding for the service transport.  The end result is that our "newer" client applications are able to use our real business objects (through referencing an assembly containing only these shared objects) as the return types from the web service calls because they make actual WCF calls.  </p>\n\n<p>We do this by not utilizing the auto-generated proxy classes and constructing our own client channel to communicate with the WCF service.  </p>\n\n<p>If you can possibly use WCF, let me know I can post some additional information.</p>\n'}]
['https://Stackoverflow.com/questions/17725', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/832/']