Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large, Complex Objects as a Web Service Result [closed]

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?

like image 687
Rob Cooper Avatar asked Aug 20 '08 10:08

Rob Cooper


People also ask

What are the disadvantages of REST API?

One of the disadvantages of RESTful APIs is that you can lose the ability to maintain state in REST, such as within sessions. It can also be more difficult for newer developers to use. It's important to understand what makes a REST API RESTful, and why these constraints exist before building your API.

What is API vulnerability?

Broken User Authentication Another common API vulnerability is the use of illegitimate tokens to gain access to endpoints. Authentication systems themselves may be compromised, or expose an API key accidentally. Attacks can exploit such authentication tokens to gain access.

What is RESTful explain its working?

A REST API (also called a “RESTful” API) is a specific type of API that follows these guidelines. REST stands for Representational State Transfer. This means that when a client requests a resource using a REST API, the server transfers back the current state of the resource in a standardized representation.

What does Hateoas stand for?

Hypermedia as the Engine of Application State (HATEOAS) is a constraint of the REST application architecture that distinguishes it from other network application architectures. With HATEOAS, a client interacts with a network application whose application servers provide information dynamically through hypermedia.


1 Answers

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.

like image 110
Cheekysoft Avatar answered Oct 22 '22 13:10

Cheekysoft