大型,复杂的对象作为Web服务结果 [英] Large, Complex Objects as a Web Service Result

查看:148
本文介绍了大型,复杂的对象作为Web服务结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好再次女士们,先生们!

Hello again ladies and gents!

OK,从我的其他问题,以下对<一个href=\"http://stackoverflow.com/questions/6681/aspnet-web-service-results-proxy-classes-and-type-conversion\"相对=nofollow> ASP.NET Web服务的结果,代理类和类型转换。我来在我的项目的一部分,我需要让我的思维帽。

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.

基本上,我们有需要从Web服务返回和消费的客户端应用程序的大型,复杂的自定义对象。

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

现在的基础上,previous的讨论,我们知道这是怎么回事,然后把代理类(ES)作为返回类型的形式。为了克服这个问题,我们需要基本的属性从一个复制到其他。

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!

所以,我开始思考,不然我们怎么能做到这一点?

我现在的想法是,让完整的序列化到XML对象,然后返回XML为从Web服务的字符串。在客户端,然后我们反序列化。这将意味着属性装潢公平一点,但至少在两个端点上的code会发光,即通过只使用.NET XML序列化。

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.

推荐答案

在.NET XML(反)序列化是pretty很好地实现。在第一个想到的,我不认为这是一个坏主意。

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

如果这两个应用程序中导入相同的C#类(ES)的定义(S),那么这就是让拷贝构造函数的行为自由的一个相对不错的方式。如果该类结构的变化,那么一切都将在双方都获得了新的类定义的工作,而无需使在Web服务消费/施工方的任何其他更改。

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.

有在编组在分解的XML轻微的开销,但是这很可能是由远程Web服务调用的开销dwarved。 .NET XML序列化是深受大多数程序员理解并应该产生易于维护的解决方案。

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.

这篇关于大型,复杂的对象作为Web服务结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆