-SerializationFormat.XML (Default)
-SerializationFormat.Binary
binary직렬화를 통해 성능을 향상시킬 수 있지만 대용량데이터 전송시 압축이 필요하다.
[WebMethod]
public string GetService()
{
//데이터 압축
byte[] data = CompressDataSet(ds);
//Base64로 형변환
return Convert.ToBase64String(data, 0, data.Length);
}
public byte[] CompressDataSet(DataSet ds)
{
//1. 데이터셋 Serialize
ds.RemotingFormat = SerializationFormat.Binary;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, ds);
byte[] inbyt = ms.ToArray();
//2. 데이터 압축
System.IO.MemoryStream objStream = new MemoryStream();
System.IO.Compression.DeflateStream objZS =
new System.IO.Compression.DeflateStream(objStream, ystem.IO.Compression.CompressionMode.Compress);
objZS.Write(inbyt, 0, inbyt.Length);
objZS.Flush();
objZS.Close();
//3. 데이터 리턴
return objStream.ToArray();
}
Gmail 연동 (0) | 2012.03.16 |
---|---|
직렬화 제어 (0) | 2008.04.18 |
직렬화 방법에 따른 크기 비교 (0) | 2008.04.18 |
객체 직렬화 (0) | 2008.04.18 |
.NET의 Enterprise Service(COM+) 이해 (0) | 2008.04.04 |