soap message

Discussion in 'ASP .Net' started by Tony Johansson, Mar 9, 2010.

  1. Hi!

    Below I have a simple console program that is using the SoapFormatter to
    serialize an object ShoppingCartItem into file.

    Assume that we serialize this object by using SoapFormatter and sent it away
    so it can be deserialized in another application on another computer. I mean
    when we deserialize we do this
    item = (ShoppingCartItem)sf.Deserialize(fs);
    knowing that the object is a ShoppingCartItem that is going to be
    deserialized

    Now to my question when writing code on the receiving application that will
    deserialize the object
    how is it possible to write code that know in advance what type of object
    that we have so a suitable cast can be done as we do here
    item = (ShoppingCartItem)sf.Deserialize(fs);
    Can somebody explain this ?

    public static void Main(string[] args)
    {
    ShoppingCartItem item = new ShoppingCartItem(4370, 423.50M, 1);
    FileStream fs = new FileStream("Test.sop", FileMode.Create);
    SoapFormatter sf = new SoapFormatter();
    sf.Serialize(fs, item);
    fs.Close();

    fs = new FileStream("tonyTest.bin", FileMode.Open);
    item = (ShoppingCartItem)sf.Deserialize(fs);
    fs.Close();
    }

    //Tony
     
    Tony Johansson, Mar 9, 2010
    #1
    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. Sham Ramakrishnan
    Replies:
    2
    Views:
    8,479
    Sham Ramakrishnan
    Jul 1, 2003
  2. rabbits77
    Replies:
    0
    Views:
    901
    rabbits77
    Feb 26, 2004
  3. John
    Replies:
    8
    Views:
    974
    iksrazal
    Mar 28, 2005
  4. mooseshoes

    To SOAP or Not To SOAP?

    mooseshoes, Sep 4, 2003, in forum: XML
    Replies:
    3
    Views:
    429
    Heinz Häberle
    Sep 21, 2003
  5. Peter van der veen

    How to add SOAP header to a SOAP message?

    Peter van der veen, Nov 8, 2006, in forum: ASP .Net Web Services
    Replies:
    6
    Views:
    643
    J. Dudgeon
    Nov 14, 2006
Loading...

Share This Page