none
How to pass a custom object over the WCF service without defining it as a DataContract. RRS feed

  • Question

  • Hi,

    I need to pass a custom object over the WCF Service without defining it as a Data Contract.

    Code :- 

        //Custom Class
    public class test {
            public int testing { get; set; }
        }
            [OperationContract]
            bool SetDataObject(string Key, Object value);
    //Call Service
    serviceObj.SetDataObject(txtKey.Text, new test(){testing =0});

    ERROR :---------------------

    Tuesday, April 29, 2014 2:30 PM

Answers

  • The simple solution would be to XML serialize the object, pass it as string data to the WCF service and have code to deserialize it back to an object.

    Of course, the WCF service side would have to know what that object is so you can cast it back to the object when you deserialize the object back.

    Tuesday, April 29, 2014 2:58 PM