We have answer of your question!

100% solved queries, no empty question

Question: Large, Complex Objects as a Web Service Result


Hello again ladies and gents!

OK, following on from my other question on ASP.NET Web Service Results, Proxy Classes and Type Conversion. I've come to a part in my project where I need to get my thinking cap on.

Basically, we have a large, complex custom object that needs to be returned from a Web Service and consumed in the client application.

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.

In this case, that is something that I would really, really, really! like to avoid!

So, it got me thinking, how else could we do this?

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.

What are your thoughts on this?

Question author Rob-cooper | Source



The .Net XML (de)serialisation is pretty nicely implemented. At first thought, I don't think this is a bad idea at all.

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.

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.

Answer author Cheekysoft

Tickanswer.com is providing the only single recommended solution of the question Large, Complex Objects as a Web Service Result under the categories i.e c# , asp.net , xml , web-services , serialization , . Our team of experts filter the best solution for you.

You may also add your answer

Thanks for contributing an answer to Tick Answer!