Binary Serialization!

Discussion in 'ASP .Net Web Services' started by mehdi, Mar 5, 2007.

  1. mehdi

    mehdi Guest

    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
     
    mehdi, Mar 5, 2007
    #1
    1. Advertising

  2. "mehdi" <> wrote in message
    news:...
    > 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
     
    John Saunders, Mar 5, 2007
    #2
    1. Advertising

  3. mehdi

    mehdi Guest

    On Mar 5, 9:41 pm, "John Saunders" <john.saunders at trizetto.com>
    wrote:
    > "mehdi" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > 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
     
    mehdi, Mar 7, 2007
    #3
  4. "mehdi" <> wrote in message
    news:...
    > On Mar 5, 9:41 pm, "John Saunders" <john.saunders at trizetto.com>
    > wrote:
    >> "mehdi" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >> > 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
     
    John Saunders, Mar 7, 2007
    #4
  5. You should use Remoting instead of Web Services.

    "mehdi" <> wrote in message
    news:...
    > On Mar 5, 9:41 pm, "John Saunders" <john.saunders at trizetto.com>
    > wrote:
    >> "mehdi" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >> > 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
    >
     
    Mariano Omar Rodriguez, Mar 7, 2007
    #5
  6. mehdi

    mehdi Guest

    On Mar 7, 6:34 pm, "John Saunders" <john.saunders at trizetto.com>
    wrote:
    > "mehdi" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > On Mar 5, 9:41 pm, "John Saunders" <john.saunders at trizetto.com>
    > > wrote:
    > >> "mehdi" <> wrote in message

    >
    > >>news:...

    >
    > >> > 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
     
    mehdi, Mar 11, 2007
    #6
  7. "mehdi" <> wrote in message
    news:...
    > On Mar 7, 6:34 pm, "John Saunders" <john.saunders at trizetto.com>
    > wrote:
    >> "mehdi" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >> > On Mar 5, 9:41 pm, "John Saunders" <john.saunders at trizetto.com>
    >> > wrote:
    >> >> "mehdi" <> wrote in message

    >>
    >> >>news:...

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


    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
     
    John Saunders, Mar 11, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex D.

    binary vs. xml serialization

    Alex D., Dec 21, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    9,377
    Alex D.
    Dec 21, 2005
  2. Replies:
    8
    Views:
    2,273
    deadsea
    Jan 2, 2005
  3. Replies:
    3
    Views:
    1,056
  4. Dimitri Ognibene
    Replies:
    4
    Views:
    796
    Dimitri Ognibene
    Sep 2, 2006
  5. Ramunas Urbonas
    Replies:
    1
    Views:
    412
    Dino Chiesa [Microsoft]
    Jul 27, 2004
Loading...

Share This Page