zoukankan      html  css  js  c++  java
  • web service notes

    1. 性能提高
      压缩传输数据, 减少多次调用, XML解析器的优化和选择, 简化标签, 缓存机制
      ref: http://www.ibm.com/developerworks/cn/webservices/0710_wangyun/index.html?S_TACT=105AGX52&S_CMP=NL&ca=dnl-cn-11212007
    2. in class library project use  WebServiceHandlerFactory to create Web service, http://www.codeproject.com/useritems/wsinaclasslibrary.asp
      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.
    3. [WebMethod(EnableSession=true)]XXX 此声明可以在WS中引用session对象, 某种程度上可以提高性能; 但需要客户端在调用时支持,默认情况下browser中调用WS时要有SESSION的,而在普通的EXE或程序中调用WS时,需要显示声明要使用cookie,否则服务器端的session无效..net 中声明如下:
      WebService1 srv = new WebService1();
      srv.CookieContainer = new CookieContainer();
      只有经过这样声明,调用的WS才会传递SESSIONID,建立在一个应用中只有一个地方可获取WS,即采用singleton模式,这样所有地方调用WS时都有sessionID支持.
    4. 利用WS上传文件,可以在CLIENT中将文件中的内容读取到byte[]中,然后调用WS接口,然后WS再将byte写入到文件中
      转换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;

  • 相关阅读:
    BUUCTF--Youngter-drive
    BUUCTF--CrackRTF
    FireShell CTF 2020 Re Simple Encryption
    2020 美国大学生数学建模论文翻译(week 2)
    仿射密码
    乘法逆元
    RC4加密与解密
    2020 BJDCTF Re encode
    2020美国大学生数学建模(MCM/ICM)A题数据及参考资料
    路由器, 美团笔试题, 差分
  • 原文地址:https://www.cnblogs.com/margiex/p/968029.html
Copyright © 2011-2022 走看看