Process a large chunk of data in Web Service. Performance, Performance,Performance
This is what I did:
1: Install Microsoft WSE 2.0
2: When you finishe the web service process and before you return the response back, use the following code to return the response
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.IO.StreamWriter sw = new System.IO.StreamWriter(ms);
XmlSerializer serializer = null;
serializer = new XmlSerializer(typeof(MyObject), "http://MYObjectService/Service.asmx/20040803");
serializer.Serialize(sw, ret);
sw.Flush();
ms.Position = 0;
SoapContext respContext = ResponseSoapContext.Current;
DimeAttachment attachment = new DimeAttachment("text/plain",
TypeFormat.MediaType,
ms);
respContext.Attachments.Add(attachment);
serializer = null;
return "OK";
That will do it.
BTW: In order to extract the attachment at the client side, you need to install the WSE as well and use the response context object to extract the entire responese out.
浙公网安备 33010602011771号