web service notes
生活随笔
收集整理的這篇文章主要介紹了
web service notes
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
壓縮傳輸數據, 減少多次調用, XML解析器的優化和選擇, 簡化標簽, 緩存機制
ref: http://www.ibm.com/developerworks/cn/webservices/0710_wangyun/index.html?S_TACT=105AGX52&S_CMP=NL&ca=dnl-cn-11212007
write a class WebServiceBase to implements webserviceHandlerFactory, then implement your web service inherit from this class, and copy this compoment into your web app bin directory, then add <add path="WSTest.asmx" verb="*" type="WSLibrary.WSTest" validate="false"/> into your web.config's httphandler section.
WebService1 srv = new WebService1();
srv.CookieContainer = new CookieContainer();
只有經過這樣聲明,調用的WS才會傳遞SESSIONID,建立在一個應用中只有一個地方可獲取WS,即采用singleton模式,這樣所有地方調用WS時都有sessionID支持.
轉換FileStream fileStream = File.OpenRead(path + fileName);為MemoryStream,再轉換為byte[].
public byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream)
??????? {
??????????? int b1;
??????????? System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
??????????? while ((b1 = theStream.ReadByte()) != -1)
??????????? {
??????????????? tempStream.WriteByte(((byte)b1));
??????????? }
??????????? return tempStream.ToArray();
??????? }
如果是將byte[]寫入到文件,則代碼如下:
{
??????????????? MemoryStream memoryStream = new MemoryStream(fs);
??????????????? FileStream fileStream = new FileStream(path + fileName, FileMode.Create);
??????????????? memoryStream.WriteTo(fileStream);
??????????????? memoryStream.Close();
??????????????? fileStream.Close();
??????????????? fileStream = null;
??????????????? memoryStream = null;
轉載于:https://www.cnblogs.com/margiex/archive/2007/11/22/968029.html
總結
以上是生活随笔為你收集整理的web service notes的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是技术,技术是什么
- 下一篇: DataGridView 单元格验证