cancel
Showing results for 
Search instead for 
Did you mean: 

Soap serialization in .Net Framework

Occasional Contributor

Soap serialization in .Net Framework

Soap serialization is tricky and it is much more harder if your class objects don't explicitly implement ISerializable interface. .Net Soap serializer does not know how to map the property of Employee unless you know the name of the underlying backing fields (funny looking names!). You have to scratch your head to figure out the backing field names or you can implement the ISerializable interface to gaurantee
the serialization (you can even debug it!).

using System;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace My.Concept.Contract
{
[Serializable]
public class Employee //: ISerializable
{
public string Name { get; set; }
public int Id { get; set; }

public Employee() { }

//public Employee(SerializationInfo info, StreamingContext context)
//{
// Name = (string)info.GetValue("Name", typeof(string));
// Id = (int)info.GetValue("Id", typeof(int));
//}
//public void GetObjectData(SerializationInfo info, StreamingContext context)
//{
// info.AddValue("Name", Name);
// info.AddValue("Id", Id);
//}
}
}

//this is implementation operation
//ns=My.Concept.Server
//class=SampleRemoteService
//dll=My.Concept.Server
public int TestByRef(int any, ref Employee employee)
{
any = 123;

employee.Id = 123;
employee.Name = "Jimmy";

return any;
}
New Here?
Join us and watch the welcome video:
Announcements