//序列化
public string SoapOutput(object obj)
{
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream memoryStream = new MemoryStream();
formatter.Serialize(memoryStream, obj);
byte[] aryByte = memoryStream.ToArray();
string base64 = Convert.ToBase64String(aryByte, 0, aryByte.Length);
memoryStream.Close();
return base64;
}
//反序列化
public object SoapInput(string base64)
{
byte[] aryByte = Convert.FromBase64String(base64);
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream memoryStream = new MemoryStream(aryByte, 0, aryByte.Length);
object obj = (Object)formatter.Deserialize(memoryStream);
memoryStream.Close();
return obj;
}