DataSet SerializationFormat
DataSet SerializationFormat
-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();
}