传递xml与传递类 [英] Passing xml vs. passing a class

查看:75
本文介绍了传递xml与传递类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两种方法可以将结构化数据传递给Web服务:


xml

===


< Order OrderId =" 123" OrderAmount = QUOT; 234" />


或班级

=====


公共课程订单

{

公共字符串OrderId;

公共deciaml OrderAmount;

}


类将被序列化为xml,在肥皂级别上将没有

的差异。


是否有任何白皮书或任何指南文件比较这两个

方法?在哪种情况下我应该使用哪一种?


例如,测试页面在传递类时不可用,但xml是

使用,我可以制作记事本并将其粘贴到测试页面。

谢谢,


-Stan

There are two ways to pass structured data to a web service:

xml
===

<Order OrderId="123" OrderAmount="234" />

or class
=====

public class Order
{
public string OrderId;
public deciaml OrderAmount;
}

Class will be serialized to xml and on soap level there will be no
difference.

Are there any white paper or any guideline document which compares these two
methods? In which cases should I use one or another?

For example, test page is not available when passing a class, but xml is
used, I can make it Notepad and paste it into the test page.
Thanks,

-Stan

推荐答案

Stan,


我不认为上面有任何白皮书。您在
WebServices中使用的类只是状态对象 - 具有Get / Set属性。因此,

它们可以表示为XML(用于结构化数据)。传递对象

而不是XMl使得更容易使用任何一方的数据 -

否则你将不得不使用XML解析器来获取值;我几乎总是

更喜欢上课。


-

Manohar Kamath

编辑, .netWire
www.dotnetwire.com

" ;斯坦" <无**** @ yahoo.com>在留言中写道

新闻:%2 ****************** @ TK2MSFTNGP14.phx.gbl ...
Stan,

I don''t think there is any whitepaper on the above. The classes you use in
WebServices are nothing but state objects -- with Get/Set properties. Hence,
they can be represented as XML (for the structured data). Passing objects
instead of XMl makes it easier to play with the data on the either side --
else you will have to use XML parsers to get values; I would almost always
prefer a class.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Stan" <no****@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
将结构化数据传递给Web服务有两种方法:

 < Order OrderId =" 123" OrderAmount = QUOT; 234" />

或上课
=====

公共课顺序
{
公共字符串OrderId;
public deciaml OrderAmount;
}

类将序列化为xml,在soap级别上将没有区别。

是否有任何白皮书或任何比较这些
两种方法的指南文件?在哪些情况下我应该使用哪一种?

例如,传递类时测试页面不可用,但是使用了xml,我可以将它作为记事本并将其粘贴到测试页。

谢谢,

-Stan
There are two ways to pass structured data to a web service:

xml
===

<Order OrderId="123" OrderAmount="234" />

or class
=====

public class Order
{
public string OrderId;
public deciaml OrderAmount;
}

Class will be serialized to xml and on soap level there will be no
difference.

Are there any white paper or any guideline document which compares these two methods? In which cases should I use one or another?

For example, test page is not available when passing a class, but xml is
used, I can make it Notepad and paste it into the test page.
Thanks,

-Stan



我更喜欢使用课程也。唯一的评论,如果有人实际测试了这个,发现这是真的或不是真的感觉

免费评论,会让速度创建属于你自己

序列化/反序列化方法。因为实现

ISerialization接口并实现构造函数允许.net

在将数据序列化为xml或任何其他格式时不使用反射?

I prefer using classes also. The only comment and if somebody has
actually tested this and found this to be true or not to be true feel
free to comment, would make that for speed create your own
serialization/deserialization methods. since implementing the
ISerialization interface and implementing the constructor allows .net
to not use reflection when serializaing data to xml or any other format?


我能想到的xml有两个好处:


1.可预测的xml格式。不依赖于xml序列化

2.易于测试


我不认为很难改变或得到任何东西:


XmlDocument doc = new XmlDocument();

doc.LoadXml(xml);

string OrderId = doc.SelectSingleNode(" // OrderId" ;)。价值:


它超过


string OrderId = Order.OrderId;


但不是很大的交易..


Manohar Kamath < MK ***** @ TAKETHISOUTkamath.com>在消息中写道

news:eY ************** @ tk2msftngp13.phx.gbl ...
There are two benefits of xml I can think of:

1. Predictable xml format. Not relying on xml serialization
2. Easy to test

I don''t think it is hard to change or get anything:

XmlDocument doc = new XmlDocument();
doc.LoadXml (xml);
string OrderId = doc.SelectSingleNode ("//OrderId").Value:

It is longer than

string OrderId = Order.OrderId;

but not a huge deal..

"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl...
Stan,
我认为上面没有任何白皮书。您在Web服务中使用的类只是状态对象 - 具有Get / Set属性。
因此,它们可以表示为XML(用于结构化数据)。传递对象而不是XMl可以更容易地使用任何一方的数据 -
否则你将不得不使用XML解析器来获取值;我几乎总是喜欢上课。

-
Manohar Kamath
编辑,.netWire
www.dotnetwire.com

" Stan" <无**** @ yahoo.com>在消息中写道
新闻:%2 ****************** @ TK2MSFTNGP14.phx.gbl ...
Stan,

I don''t think there is any whitepaper on the above. The classes you use in
WebServices are nothing but state objects -- with Get/Set properties. Hence, they can be represented as XML (for the structured data). Passing objects
instead of XMl makes it easier to play with the data on the either side --
else you will have to use XML parsers to get values; I would almost always
prefer a class.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Stan" <no****@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
有两种方式将结构化数据传递给Web服务:

xml
===

< Order OrderId =" 123" OrderAmount = QUOT; 234" />

或上课
=====

公共课顺序
{
公共字符串OrderId;
public deciaml OrderAmount;
}

类将序列化为xml,在soap级别上将没有区别。

是否有任何白皮书或任何比较这些
There are two ways to pass structured data to a web service:

xml
===

<Order OrderId="123" OrderAmount="234" />

or class
=====

public class Order
{
public string OrderId;
public deciaml OrderAmount;
}

Class will be serialized to xml and on soap level there will be no
difference.

Are there any white paper or any guideline document which compares these


两个

方法的指南文件?在哪些情况下我应该使用哪一种?

例如,传递类时测试页面不可用,但是使用了xml,我可以将它作为记事本并将其粘贴到测试页。

谢谢,

methods? In which cases should I use one or another?

For example, test page is not available when passing a class, but xml is
used, I can make it Notepad and paste it into the test page.
Thanks,

-Stan



这篇关于传递xml与传递类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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