HighTechTalks DotNet Forums  

what's the best way to pass XML document as a remoting argument?

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss what's the best way to pass XML document as a remoting argument? in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Keith Langer
 
Posts: n/a

Default what's the best way to pass XML document as a remoting argument? - 10-24-2006 , 09:57 PM






Hi,

I'm looking for the most efficient way to pass an XML document into a
remoting call. I know that I can return an XMLDocument from a remoting
call, but passing one as an argument causes errors. If I pass the XML
as a string, I believe that all tags will get URL-encoded, making the
document much bigger. I supposed that I could base64 encode it. Is
there a way to just pass it as straight binary data?

thanks,
Keith Langer


Reply With Quote
  #2  
Old   
Günter Prossliner
 
Posts: n/a

Default Re: what's the best way to pass XML document as a remoting argument? - 10-25-2006 , 06:08 AM






Hello!

Quote:
I'm looking for the most efficient way to pass an XML document into a
remoting call. I know that I can return an XMLDocument from a
remoting call, but passing one as an argument causes errors.
Because the XML-Document is not derived by MarshalByRef object and not
serializable you cannot pass it through remoting directly.

Quote:
If I
pass the XML as a string, I believe that all tags will get
URL-encoded, making the document much bigger.
This depends on the kind of formatter you use. A Xml / Soap Formatter MAY
encode the XML-String. A binary formatter does not.

Quote:
I supposed that I
could base64 encode it. Is there a way to just pass it as straight
binary data?
This depends on the formatter. The Binary Formatter can do it (others can
also do it, but the data may be encoded in most cases (depends on the
implementation)).


If you have to deal with really "big" xml-files, and you can control both
the client and the server, it may be an option for you to use some kind of
compression (like GZipStream). Because XML is very redundant GZIP will
compress the data very well.

Example:

// compress
XmlDocument doc = ...;
MemoryStream ms = new MemoryStream();
GZipStream zipStream = new GZipStream(ms, CompressionMode.Compress);
doc.Save(zipStream);
zipStream.Close();

byte[] compressed = ms.ToArray();
ms.Close();


//decompress
MemoryStream ms = new MemoryStream(data);
GZipStream zipStream = new GZipStream(ms, CompressionMode.Decompress);
doc.Load(zipStream);
zipStream.Close();
ms.Close();


OK?


GP




Reply With Quote
  #3  
Old   
Keith Langer
 
Posts: n/a

Default Re: what's the best way to pass XML document as a remoting argument? - 10-25-2006 , 09:11 AM



Gunter,

The documents are about 100K, so there's probably not a lot of need for
compression (I'd be trading bandwidth for CPU time to compress and
deflate). I tested one of these documents and found that URLEncode
expands it by about 50%, as opposed to 33% for base64. That's probably
not a huge deal. What exactly happens with binary encoding, and how
does it affect the document size? Do you have a good example of using
binary encoding?

Is there a way to see exactly what gets passed via the remoting call
and determine its size?

thanks,
Keith



Günter Prossliner wrote:
Quote:
Hello!

I'm looking for the most efficient way to pass an XML document into a
remoting call. I know that I can return an XMLDocument from a
remoting call, but passing one as an argument causes errors.

Because the XML-Document is not derived by MarshalByRef object and not
serializable you cannot pass it through remoting directly.

If I
pass the XML as a string, I believe that all tags will get
URL-encoded, making the document much bigger.

This depends on the kind of formatter you use. A Xml / Soap Formatter MAY
encode the XML-String. A binary formatter does not.

I supposed that I
could base64 encode it. Is there a way to just pass it as straight
binary data?

This depends on the formatter. The Binary Formatter can do it (others can
also do it, but the data may be encoded in most cases (depends on the
implementation)).


If you have to deal with really "big" xml-files, and you can control both
the client and the server, it may be an option for you to use some kind of
compression (like GZipStream). Because XML is very redundant GZIP will
compress the data very well.

Example:

// compress
XmlDocument doc = ...;
MemoryStream ms = new MemoryStream();
GZipStream zipStream = new GZipStream(ms, CompressionMode.Compress);
doc.Save(zipStream);
zipStream.Close();

byte[] compressed = ms.ToArray();
ms.Close();


//decompress
MemoryStream ms = new MemoryStream(data);
GZipStream zipStream = new GZipStream(ms, CompressionMode.Decompress);
doc.Load(zipStream);
zipStream.Close();
ms.Close();


OK?


GP


Reply With Quote
  #4  
Old   
Günter Prossliner
 
Posts: n/a

Default Re: what's the best way to pass XML document as a remoting argument? - 10-27-2006 , 03:59 AM



Hi Keith!

Quote:
The documents are about 100K, so there's probably not a lot of need
for compression (I'd be trading bandwidth for CPU time to compress and
deflate).
The question is: What restricts you more? The CPU or the bandwidth?

Quote:
I tested one of these documents and found that URLEncode
expands it by about 50%, as opposed to 33% for base64.
URLEncode from what? Binary data??? URL Encoding a string should not expand
the size by 50%.

Quote:
That's
probably not a huge deal. What exactly happens with binary encoding,
and how does it affect the document size? Do you have a good example
of using binary encoding?
What do you meen with "Binary Encoding"? BinaryFormatting?

This depends on the way remoting is configured for you application / object.
When you use a TcpChannel, the binary-Formatter is choosen by default.

Quote:
Is there a way to see exactly what gets passed via the remoting call
and determine its size?
You can use tools like etherreal for this. If you want to determinate the
size of a single object, you can serialize the instance into Memory
(BinarySerializer / MemoryStream), and check out how much memory is used.



GP




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.