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...
(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