Binary Serialization!

M

mehdi

Hi folks,

I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:

public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}

Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).

Thanks in advance.
Mehdi
 
J

John Saunders

mehdi said:
Hi folks,

I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:

public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}

Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).

Did you know that Web Services communicate using XML? So, how are you
planning to have binary inside of your XML (which is a text-based format)?

I also presume from your statement about building the proxy yourself that
you are only interested in having your own code reference this service.
Because it's certain that other code will assume that XML is XML, not
binary.

John
 
M

mehdi

Hi folks,
I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:
public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}
Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).

Did you know that Web Services communicate using XML? So, how are you
planning to have binary inside of your XML (which is a text-based format)?

I also presume from your statement about building the proxy yourself that
you are only interested in having your own code reference this service.
Because it's certain that other code will assume that XML is XML, not
binary.

John

Absolutely. I've developed the proxy myself, and anyone who's going to
consume my exposed services needs to use my hand-made proxy, or else,
it won't be able to communicate with the service. I'm not interested
in interoperability, (in this special application), and therefore...

On the other hand, Binary formatting is much more faster than any
other formatter on the planet. It support Cyclic References, Generic
types and the like whilst the XML Formatter and/or Soap Formatter
don't support them. (This discussion deserves an article I'm working
on already...)

To put the interoperability aside, now the question is that (again) is
there anyway to change the default serialization from XML to Binary
without going through the hard steps of serializing/deserializing each
formal parameter (as well as the return value) of each web method?

TIA,
Mehdi
 
J

John Saunders

mehdi said:
Hi folks,
I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:
public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}
Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).

Did you know that Web Services communicate using XML? So, how are you
planning to have binary inside of your XML (which is a text-based
format)?

I also presume from your statement about building the proxy yourself that
you are only interested in having your own code reference this service.
Because it's certain that other code will assume that XML is XML, not
binary.

John

Absolutely. I've developed the proxy myself, and anyone who's going to
consume my exposed services needs to use my hand-made proxy, or else,
it won't be able to communicate with the service. I'm not interested
in interoperability, (in this special application), and therefore...

On the other hand, Binary formatting is much more faster than any
other formatter on the planet. It support Cyclic References, Generic
types and the like whilst the XML Formatter and/or Soap Formatter
don't support them. (This discussion deserves an article I'm working
on already...)

To put the interoperability aside, now the question is that (again) is
there anyway to change the default serialization from XML to Binary
without going through the hard steps of serializing/deserializing each
formal parameter (as well as the return value) of each web method?

Mehdi,

Before you work on the overall serialization issue, have you done a proof of
concept to see if it's even possible to include binary within XML? Or will
your web service not use XML at all?

John
 
M

Mariano Omar Rodriguez

You should use Remoting instead of Web Services.

mehdi said:
Hi folks,
I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:
public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}
Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).

Did you know that Web Services communicate using XML? So, how are you
planning to have binary inside of your XML (which is a text-based
format)?

I also presume from your statement about building the proxy yourself that
you are only interested in having your own code reference this service.
Because it's certain that other code will assume that XML is XML, not
binary.

John

Absolutely. I've developed the proxy myself, and anyone who's going to
consume my exposed services needs to use my hand-made proxy, or else,
it won't be able to communicate with the service. I'm not interested
in interoperability, (in this special application), and therefore...

On the other hand, Binary formatting is much more faster than any
other formatter on the planet. It support Cyclic References, Generic
types and the like whilst the XML Formatter and/or Soap Formatter
don't support them. (This discussion deserves an article I'm working
on already...)

To put the interoperability aside, now the question is that (again) is
there anyway to change the default serialization from XML to Binary
without going through the hard steps of serializing/deserializing each
formal parameter (as well as the return value) of each web method?

TIA,
Mehdi
 
M

mehdi

Hi folks,
I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:
public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}
Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).
Did you know that Web Services communicate using XML? So, how are you
planning to have binary inside of your XML (which is a text-based
format)?
I also presume from your statement about building the proxy yourself that
you are only interested in having your own code reference this service.
Because it's certain that other code will assume that XML is XML, not
binary.
John
Absolutely. I've developed the proxy myself, and anyone who's going to
consume my exposed services needs to use my hand-made proxy, or else,
it won't be able to communicate with the service. I'm not interested
in interoperability, (in this special application), and therefore...
On the other hand, Binary formatting is much more faster than any
other formatter on the planet. It support Cyclic References, Generic
types and the like whilst the XML Formatter and/or Soap Formatter
don't support them. (This discussion deserves an article I'm working
on already...)
To put the interoperability aside, now the question is that (again) is
there anyway to change the default serialization from XML to Binary
without going through the hard steps of serializing/deserializing each
formal parameter (as well as the return value) of each web method?

Mehdi,

Before you work on the overall serialization issue, have you done a proof of
concept to see if it's even possible to include binary within XML? Or will
your web service not use XML at all?

John

Hi,
Well, the answer is that binary information is finally converted to
base64-encoded strings. On the other hand, there are technologies out
there (including DIME) that let you transfer binary information over
the wire. These are all out of question and has got nothing to do with
my question. Lets start from scratch.

Consider a web method, say,

public void UpdateWhateverEntityObject(ref MyEntity entity)
{
}

the MyEntity class uses circular-references, generic types and
whatever that neither XML Serializer, nor the Soap Serializer can
serialize/deserialize that. To make things worst, as soon as the
entity gets updated, it's to reflect new unique identifies or whatever
changes in the data layer to the caller. If there were a way that I
could dictate to the Web Service that it has to serialize/deserialize
data in binary format (and then converts them to the base-64 encoded
string, transfer it over the wire using DIME or whatever), instead of
XML serialization, then it would be possible to take benefit of all
those issues that XML/SOAP serializations cannot handle.

To do so, I changed the above mentioned prototype to:

public void UpdateWhateverEntityObject(ref Byte[] entity)
{
}

This way, I could do the serialization/deserialization myself (as
needed) and everything will just work fine. However, developing such
methods is really pain in the ass (although all are done in 3 lines of
code). I do know that the Byte array eventually is converted to
base-64 encoded string, but I do not care about this.

Now do you have any idea?

TIA,
Mehdi
 
J

John Saunders

mehdi said:
On Mar 5, 9:41 pm, "John Saunders" <john.saunders at trizetto.com>
wrote:


Hi folks,
I would like to know that is there anyway to change the default
serialization from XML to Binary? If not, what's the best approach
to
accomplish binary serialization under an ASP.NET Web Service? I've
used the following format to do it so far, however, it's really
painless:
public Boolean SyncEntity(ref Byte[] data)
{
//Deserialize the data into an entity object.
//update the entity
//Serialize the entity back into data
}
Is there any official way to do the same thing? (assuming that I'll
develop the proxy myself).
Did you know that Web Services communicate using XML? So, how are you
planning to have binary inside of your XML (which is a text-based
format)?
I also presume from your statement about building the proxy yourself
that
you are only interested in having your own code reference this
service.
Because it's certain that other code will assume that XML is XML, not
binary.

Absolutely. I've developed the proxy myself, and anyone who's going to
consume my exposed services needs to use my hand-made proxy, or else,
it won't be able to communicate with the service. I'm not interested
in interoperability, (in this special application), and therefore...
On the other hand, Binary formatting is much more faster than any
other formatter on the planet. It support Cyclic References, Generic
types and the like whilst the XML Formatter and/or Soap Formatter
don't support them. (This discussion deserves an article I'm working
on already...)
To put the interoperability aside, now the question is that (again) is
there anyway to change the default serialization from XML to Binary
without going through the hard steps of serializing/deserializing each
formal parameter (as well as the return value) of each web method?

Mehdi,

Before you work on the overall serialization issue, have you done a proof
of
concept to see if it's even possible to include binary within XML? Or
will
your web service not use XML at all?

John

Hi,
Well, the answer is that binary information is finally converted to
base64-encoded strings. On the other hand, there are technologies out
there (including DIME) that let you transfer binary information over
the wire. These are all out of question and has got nothing to do with
my question. Lets start from scratch.

Consider a web method, say,

public void UpdateWhateverEntityObject(ref MyEntity entity)
{
}

the MyEntity class uses circular-references, generic types and
whatever that neither XML Serializer, nor the Soap Serializer can
serialize/deserialize that. To make things worst, as soon as the
entity gets updated, it's to reflect new unique identifies or whatever
changes in the data layer to the caller. If there were a way that I
could dictate to the Web Service that it has to serialize/deserialize
data in binary format (and then converts them to the base-64 encoded
string, transfer it over the wire using DIME or whatever), instead of
XML serialization, then it would be possible to take benefit of all
those issues that XML/SOAP serializations cannot handle.

To do so, I changed the above mentioned prototype to:

public void UpdateWhateverEntityObject(ref Byte[] entity)
{
}

This way, I could do the serialization/deserialization myself (as
needed) and everything will just work fine. However, developing such
methods is really pain in the ass (although all are done in 3 lines of
code). I do know that the Byte array eventually is converted to
base-64 encoded string, but I do not care about this.

Ok, you've probably said this already, and I'm probably forgetting. But you
don't intend for this web service to be used by anyone else, right?

Also, have you looked at .NET Remoting?

You're basically trying to bend Web Services into something more generic
than it's intended for. You might succeed, but then you'll be the only one
who can use the service, or it will only be usable with a client that you
create.

That said, if you have to use Web Services, and if you have to be able to
send arbitrary binary data, then you should simply use byte arrays and
serialize it yourself. Distribute the serialization code along with your
client software, and you won't be any worse off than before - it will still
be the case that only people using your client software will be able to use
your server.

Surely it shouldn't be too hard to create the serialization code for this.
Binary serialization is fairly easy to use. Then, it's just a question of
converting the binary stream into a byte array for transport.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top