将非数据集XML返回给vb.net客户端? [英] return non-dataset XML to vb.net client?

查看:74
本文介绍了将非数据集XML返回给vb.net客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我在languages.vb上发布了这个...如果你使用了很多东西,我就无法弄明白事情的发展方向。


大家好......我正在寻找一个与

相关的示例(或一个指针)。我有一个WebService(它工作),它获取数据,将其转换为

XML并将其返回给vb.net客户端。 数据是指数据。虽然代表了对于vb.net客户端创建的对象的
属性值,现在

必须加载。


Just关于我发现的每个例子都演示了如何表,行,

列这样可以获取,更新等等,但我有它工作,所以

客户端没有任何关于数据来源的信息

来自或如果它甚至从桌子上取下来。它是客户端的所有对象(和对象的集合)。


因此,必须在服务器上创建的XML字符串是混合的事情。

它包括来自一个或多个表格的数据,但也包括其他一些表格的结果。b&b知识它有(例如服务器上的日期和时间)。返回的

XML将是构成对象的属性的组合。


我正在寻找一种方法来干净地创建这个复合XML

服务器端的字符串以及在客户端再次分解它的同样优雅的方式

因此可以将值分配给新创建的对象。有什么想法吗?


我已经使用VB6,DCOM和属性包了但是我想得到

之前所有转换为.NET十年了:-)一个网站,一篇

的文章,一本书,我会拿走我能得到的东西。


谢谢,

汤姆

(I posted this in languages.vb also... I can''t figure out where things go if
you use a little of a lot of things)

Hi all... I''m looking for an example (or a pointer to one) related to the
following. I have a WebService (it works) that fetches data, turns it into
XML and returns it to a vb.net client. The "data" though represents
property values for an object which the vb.net client has created and now
has to load.

Just about every example I have found demonstrates how "tables, rows,
columns" and such can be fetched, updated, etc. but I have it working so
that nothing on the client side knows a thing about where the data comes
from or if it is even fetched from a table at all. It is all objects (and
collections of objects) on the client side.

So the XML string that has to be created on the server is a mix of things.
It includes data from one or more tables but also the result of some other
"knowledge" that it has (the date and time on the server for instance). The
XML returned will be a composite of the properties that make up the object.

I''m looking for a way to cleanly create this composite XML string on the
server side and an equally elegant way to break it down again on the client
so the values can be assigned to the newly created object. Any ideas?

I have it all working with VB6, DCOM and property bags but I''d like to get
it all converted to .NET before the decade is out :-) A website, an
article, a book, I''ll take what I can get.

Thanks,
Tom

推荐答案

ick

汤姆,

我真的不明白为什么要发送XML?

如果你打算在客户端创建对象,为什么不发送

对象?


例如,创建一个返回自定义类型的Web服务,并返回该类型。


然后在客户端,响应是一个这种类型的实例。


换句话说,.NET运行时负责序列化和对象图的反序列化(和来自)XML。 XML用于电汇,但你不需要在你的

应用逻辑中与XML或DOM进行交互。


你这样做:

服务器端:

创建对象图

发送它作为回复

客户端:

获取响应对象

可以正常工作。 .. 。

这有用吗?


------


另一方面,如果你发送和接收XML,然后实际上你将在你的应用程序中执行此操作:

服务器端:

创建对象图

将其序列化为XML

将该字符串发送给客户端

客户端:

获取xml字符串

对它进行反序列化(手动??!)到对象图中

可以对它进行处理...


这好像你在做你需要做更多的工作...


如果你真的坚持自己做序列化,那么你可以这样做(对不起,不是VB) :


服务器端:


[WebMethod]

公共字符串GetRawXml()

{

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

MyCustomType instance = new MyCustomType();

//在这里填充MyCustomType ....(填写对象图)


System.IO .StringWriter sw = new System.IO.StringWriter();

System.Xml.Serialization.XmlSerializer s1 = new

System.Xml.Serialization.XmlSerializer(typeof(MyCu) stomType));

s1.Serialize(sw,instance);

返回sw.ToString();

}
< br $>
客户端:


string s = MyWebService.GetRawXml();

System.Xml.XmlDocument doc = new System.Xml .XmlDocument();

doc.LoadXml(s);

//在这里,你将从给定的

手动构建对象图XmlDocument

//然后,在对象图上做一些工作

-

Dino Chiesa

Microsoft Developer分部

dinoch @ online。我不知道怎么回事。 c o m

" Tom Leylan" < ge*@iamtiredofspam.com>在消息中写道

新闻:T7 ******************* @ twister.nyc.rr.com ...
ick
Tom,

I don''t really get why you are sending XML ?
If you are just going to create objects on the client side, why not send
objects?

Eg, make a webservice that returns a custom type , and return that type.

Then on the client side, the response is an instance of that type.

In other words, the .NET runtime takes care of serialization and
de-serialization of the object graph into (and from) XML. XML is used on
the wire but you don''t need to interact with XML or the DOM within your
applicaiton logic.

You do this:
server side:
create object graph
send it as a response
client side:
get response object
do work on it. .. . .
Does this work??

------

On the other hand if you send and receive XML, then in effect you would be
doing this within your application:
server side:
create your object graph
serialize it to XML
send that string to client
client side:
get xml string
de-serialize it (manually??!) into an object graph
do work on it...

This seems like you are doing more work that you need to...

If you really insist on doing the serialization yourself, then you could do
this (sorry, not VB):

server side:

[WebMethod]
public string GetRawXml()
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
MyCustomType instance= new MyCustomType ();
// fill MyCustomType here.... (fill in the object graph)

System.IO.StringWriter sw = new System.IO.StringWriter();
System.Xml.Serialization.XmlSerializer s1 = new
System.Xml.Serialization.XmlSerializer(typeof(MyCu stomType));
s1.Serialize(sw, instance);
return sw.ToString();
}

client side:

string s= MyWebService.GetRawXml();
System.Xml.XmlDocument doc= new System.Xml.XmlDocument();
doc.LoadXml(s);
// here, you would manually construct the object graph from the given
XmlDocument
// then, do some work on the object graph
--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m

"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message
news:T7*******************@twister.nyc.rr.com...
(我在languages.vb中发布了这个...如果你使用了很多东西,我就无法弄清楚
的地方)

大家好。 ..我正在寻找一个与
以下相关的例子(或指向一个的指针)。我有一个WebService(它工作),它获取数据,将
转换为XML并将其返回给vb.net客户端。 数据是指数据。虽然代表了vb.net客户端创建的对象的属性值,现在还要加载。

几乎我发现的每个例子都演示了如何表,行,
列这样可以获取,更新,等等,但我有它工作,以至于客户端上没有任何东西知道数据来自何处或者甚至是从表中取出的东西。它是客户端的所有对象(和对象集合)。

因此,必须在服务器上创建的XML字符串是各种各样的东西。
它包括来自一个或多个表格的数据,但也包括一些其他知识的结果。它有(例如服务器上的日期和时间)。
返回的XML将是组成
对象的属性的组合。
我正在寻找一种在
服务器上干净地创建这个复合XML字符串的方法在
客户端再次分解它的方法和同样优雅的方法,以便可以将值分配给新创建的对象。有什么想法吗?

我已经全部使用VB6,DCOM和属性包但我想在十年之前将它们全部转换为.NET :-) A网站,一篇
文章,一本书,我会拿走我能得到的东西。

谢谢,
Tom
(I posted this in languages.vb also... I can''t figure out where things go if you use a little of a lot of things)

Hi all... I''m looking for an example (or a pointer to one) related to the
following. I have a WebService (it works) that fetches data, turns it into XML and returns it to a vb.net client. The "data" though represents
property values for an object which the vb.net client has created and now
has to load.

Just about every example I have found demonstrates how "tables, rows,
columns" and such can be fetched, updated, etc. but I have it working so
that nothing on the client side knows a thing about where the data comes
from or if it is even fetched from a table at all. It is all objects (and
collections of objects) on the client side.

So the XML string that has to be created on the server is a mix of things.
It includes data from one or more tables but also the result of some other
"knowledge" that it has (the date and time on the server for instance). The XML returned will be a composite of the properties that make up the object.
I''m looking for a way to cleanly create this composite XML string on the
server side and an equally elegant way to break it down again on the client so the values can be assigned to the newly created object. Any ideas?

I have it all working with VB6, DCOM and property bags but I''d like to get
it all converted to .NET before the decade is out :-) A website, an
article, a book, I''ll take what I can get.

Thanks,
Tom



" Dino Chiesa [Microsoft]" <二**** @ online.microsoft.com>写道......
"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote...
我真的不明白为什么要发送XML?
如果你只想在客户端创建对象,为什么不发送<对象?


你好Dino ...我可以成为你的朋友:-)我开始使用XML因为我认为

就是这样做的。它目前工作(在VB6中)有一个字节流

我很高兴但是我总是会听一个更好的主意。

例如,make返回自定义类型并返回该类型的Web服务。
然后在客户端,响应是该类型的实例。

换句话说,.NET运行时需要小心序列化和将对象图反序列化为(和来自)XML。 XML用在电线上,但你不需要在你的应用逻辑中与XML或DOM交互。

你这样做:
服务器方:
创建对象图
发送它作为响应
客户端:
获取响应对象
做就可以了。 .. 。

这有用吗?
I don''t really get why you are sending XML ?
If you are just going to create objects on the client side, why not send
objects?
Hi Dino... Can I be your friend :-) I started using XML because I thought
that was the way to do it. It currently works (in VB6) with a byte stream
and I''m happy with that but I''ll always listen to a better idea.
Eg, make a webservice that returns a custom type , and return that type.
Then on the client side, the response is an instance of that type.

In other words, the .NET runtime takes care of serialization and
de-serialization of the object graph into (and from) XML. XML is used on
the wire but you don''t need to interact with XML or the DOM within your
applicaiton logic.

You do this:
server side:
create object graph
send it as a response
client side:
get response object
do work on it. .. . .

Does this work??




它对我有用!我当前的实现转换为字符串,以便更快地传输

但是如果这就是.NET将要做的事情我会喜欢

让.NET处理细节。


(我总是在临时看这个东西但是......)有什么方法你可以

指出我的一个例子为了给它这个

自我序列化的能力,我必须做什么?我学得很快,但我似乎在搜索相当慢。

也许问题是我得到1,900,000次点击:-)


谢谢,

Tom



It works for me! My current implementation converted to strings to make the
transmission faster but if that is what .NET is going to do anyway I''d love
to let .NET handle the details.

(I always look this stuff in the interim but...) is there any way you can
point me to an example of what my class has to do in order to give it this
ability to self-serialize? I learn fast but I seem to "search" rather slow.
Maybe the problem is when I get 1,900,000 hits :-)

Thanks,
Tom


" Dino Chiesa [Microsoft]" <二**** @ online.microsoft.com>写道......


Dino ......我发现了一些关于序列化和格式化的文章。我必须现在阅读更多有关此内容的信息,因为它看起来与我打算完全相同。


也可以你有什么意见(一般来说)

值得将它放入肥皂包装机吗?我不打算通过互联网或普通大众提供数据,但它可能会为客户提供一个有趣的演示,如果没有'它有很大的缺点

可能是一件好事。


谢谢,

汤姆


"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote...

Dino... I found some articles on serialization and formatters. I have to
read more about this now as it looks exactly like what I was intending to
do.

Also do you have any opinions on whether it''s (generally speaking)
worthwhile to put it in a soap wrapper at this point? I''m not going to
offer the data through the Internet or to the general public but it might
make for an interesting demo to a client and if there isn''t much downside it
might be a good thing.

Thanks,
Tom



这篇关于将非数据集XML返回给vb.net客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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