web service notes
生活随笔
收集整理的這篇文章主要介紹了
web service notes
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
壓縮傳輸數(shù)據(jù), 減少多次調(diào)用, XML解析器的優(yōu)化和選擇, 簡(jiǎn)化標(biāo)簽, 緩存機(jī)制
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();
只有經(jīng)過(guò)這樣聲明,調(diào)用的WS才會(huì)傳遞SESSIONID,建立在一個(gè)應(yīng)用中只有一個(gè)地方可獲取WS,即采用singleton模式,這樣所有地方調(diào)用WS時(shí)都有sessionID支持.
轉(zhuǎn)換FileStream fileStream = File.OpenRead(path + fileName);為MemoryStream,再轉(zhuǎn)換為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[]寫(xiě)入到文件,則代碼如下:
{
??????????????? MemoryStream memoryStream = new MemoryStream(fs);
??????????????? FileStream fileStream = new FileStream(path + fileName, FileMode.Create);
??????????????? memoryStream.WriteTo(fileStream);
??????????????? memoryStream.Close();
??????????????? fileStream.Close();
??????????????? fileStream = null;
??????????????? memoryStream = null;
轉(zhuǎn)載于:https://www.cnblogs.com/margiex/archive/2007/11/22/968029.html
總結(jié)
以上是生活随笔為你收集整理的web service notes的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 什么是技术,技术是什么
- 下一篇: (转贴) C#编码标准--编码习惯